diff options
author | Sergey V. Udaltsov <svu@src.gnome.org> | 2007-10-08 17:13:57 +0000 |
---|---|---|
committer | Sergey V. Udaltsov <svu@src.gnome.org> | 2007-10-08 17:13:57 +0000 |
commit | f3ee9cecd6541123c9b2c65055cae9500559abfb (patch) | |
tree | 84b96ac97f4bdc157532485bd037f883c7424889 | |
parent | a5f5722918b2ae845f312bbb74de4a5fe2909eb4 (diff) | |
download | libgnomekbd-f3ee9cecd6541123c9b2c65055cae9500559abfb.tar.gz |
getting rid of stupid dbus client-server
svn path=/trunk/; revision=178
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | capplet/.indent.pro | 2 | ||||
-rw-r--r-- | capplet/gkbd-indicator-plugins-capplet.c | 608 | ||||
-rw-r--r-- | capplet/gkbd-indicator-plugins-capplet.h | 22 | ||||
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | libgnomekbd/Makefile.am | 15 | ||||
-rw-r--r-- | libgnomekbd/gkbd-config-registry.c | 201 | ||||
-rw-r--r-- | libgnomekbd/gkbd-config-registry.h | 65 | ||||
-rw-r--r-- | libgnomekbd/gkbd-config-registry.xml | 16 | ||||
-rw-r--r-- | libgnomekbd/gkbd-desktop-config.c | 199 | ||||
-rw-r--r-- | libgnomekbd/gkbd-desktop-config.h | 31 | ||||
-rw-r--r-- | libgnomekbd/gkbd-indicator-config.c | 2 | ||||
-rw-r--r-- | libgnomekbd/gkbd-indicator.c | 16 | ||||
-rw-r--r-- | libgnomekbd/gkbd-keyboard-config.c | 2 | ||||
-rw-r--r-- | test/Makefile.am | 15 | ||||
-rwxr-xr-x | test/gkbd-config-registry-client.sh | 41 | ||||
-rw-r--r-- | test/gkbd-config-registry-server.c | 58 |
17 files changed, 482 insertions, 831 deletions
@@ -1,3 +1,17 @@ +2007-10-08 svu + + * capplet/gkbd-indicator-plugins-capplet.c, + capplet/gkbd-indicator-plugins-capplet.h, capplet/.indent.pro, + configure.in, libgnomekbd/gkbd-config-registry.xml, + libgnomekbd/gkbd-keyboard-config.c, + libgnomekbd/gkbd-config-registry.c, libgnomekbd/gkbd-indicator.c, + libgnomekbd/gkbd-desktop-config.c, + libgnomekbd/gkbd-indicator-config.c, + libgnomekbd/gkbd-config-registry.h, libgnomekbd/gkbd-desktop-config.h, + libgnomekbd/Makefile.am, test/gkbd-config-registry-client.sh, + test/gkbd-config-registry-server.c, test/Makefile.am: getting rid of + stupid dbus client-server + 2007-09-17 svu * configure.in, NEWS: release 2.20 diff --git a/capplet/.indent.pro b/capplet/.indent.pro new file mode 100644 index 0000000..bdff074 --- /dev/null +++ b/capplet/.indent.pro @@ -0,0 +1,2 @@ +-kr -i8 -pcs -lps -psl + diff --git a/capplet/gkbd-indicator-plugins-capplet.c b/capplet/gkbd-indicator-plugins-capplet.c index d2e0f82..e05ca67 100644 --- a/capplet/gkbd-indicator-plugins-capplet.c +++ b/capplet/gkbd-indicator-plugins-capplet.c @@ -36,61 +36,63 @@ static GMainLoop *loop; extern void CappletFillActivePluginList (GkbdIndicatorPluginsCapplet * gipc) { - GtkWidget *activePlugins = CappletGetGladeWidget (gipc, "activePlugins"); - GtkListStore *activePluginsModel = - GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (activePlugins))); - GSList *pluginPathNode = gipc->applet_cfg.enabled_plugins; - GHashTable *allPluginRecs = gipc->plugin_manager.all_plugin_recs; - - gtk_list_store_clear (activePluginsModel); - if (allPluginRecs == NULL) - return; - - while (pluginPathNode != NULL) - { - GtkTreeIter iter; - const char *fullPath = (const char *) pluginPathNode->data; - const GkbdIndicatorPlugin *plugin = - gkbd_indicator_plugin_manager_get_plugin (&gipc->plugin_manager, - fullPath); - if (plugin != NULL) - { - gtk_list_store_append (activePluginsModel, &iter); - gtk_list_store_set (activePluginsModel, &iter, - NAME_COLUMN, plugin->name, - FULLPATH_COLUMN, fullPath, -1); + GtkWidget *activePlugins = + CappletGetGladeWidget (gipc, "activePlugins"); + GtkListStore *activePluginsModel = + GTK_LIST_STORE (gtk_tree_view_get_model + (GTK_TREE_VIEW (activePlugins))); + GSList *pluginPathNode = gipc->applet_cfg.enabled_plugins; + GHashTable *allPluginRecs = gipc->plugin_manager.all_plugin_recs; + + gtk_list_store_clear (activePluginsModel); + if (allPluginRecs == NULL) + return; + + while (pluginPathNode != NULL) { + GtkTreeIter iter; + const char *fullPath = (const char *) pluginPathNode->data; + const GkbdIndicatorPlugin *plugin = + gkbd_indicator_plugin_manager_get_plugin (&gipc-> + plugin_manager, + fullPath); + if (plugin != NULL) { + gtk_list_store_append (activePluginsModel, &iter); + gtk_list_store_set (activePluginsModel, &iter, + NAME_COLUMN, plugin->name, + FULLPATH_COLUMN, fullPath, -1); + } + + pluginPathNode = g_slist_next (pluginPathNode); } - - pluginPathNode = g_slist_next (pluginPathNode); - } } static char * CappletGetSelectedActivePluginPath (GkbdIndicatorPluginsCapplet * gipc) { - GtkTreeView *pluginsList = - GTK_TREE_VIEW (CappletGetGladeWidget (gipc, "activePlugins")); - return CappletGetSelectedPluginPath (pluginsList, gipc); + GtkTreeView *pluginsList = + GTK_TREE_VIEW (CappletGetGladeWidget (gipc, "activePlugins")); + return CappletGetSelectedPluginPath (pluginsList, gipc); } char * CappletGetSelectedPluginPath (GtkTreeView * pluginsList, GkbdIndicatorPluginsCapplet * gipc) { - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (pluginsList)); - GtkTreeSelection *selection = - gtk_tree_view_get_selection (GTK_TREE_VIEW (pluginsList)); - GtkTreeIter selectedIter; - - if (gtk_tree_selection_get_selected (selection, NULL, &selectedIter)) - { - char *fullPath = NULL; - - gtk_tree_model_get (model, &selectedIter, - FULLPATH_COLUMN, &fullPath, -1); - return fullPath; - } - return NULL; + GtkTreeModel *model = + gtk_tree_view_get_model (GTK_TREE_VIEW (pluginsList)); + GtkTreeSelection *selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (pluginsList)); + GtkTreeIter selectedIter; + + if (gtk_tree_selection_get_selected + (selection, NULL, &selectedIter)) { + char *fullPath = NULL; + + gtk_tree_model_get (model, &selectedIter, + FULLPATH_COLUMN, &fullPath, -1); + return fullPath; + } + return NULL; } static void @@ -98,286 +100,356 @@ CappletActivePluginsSelectionChanged (GtkTreeSelection * selection, GkbdIndicatorPluginsCapplet * gipc) { - GtkWidget *activePlugins = CappletGetGladeWidget (gipc, "activePlugins"); - GtkTreeModel *model = - gtk_tree_view_get_model (GTK_TREE_VIEW (activePlugins)); - GtkTreeIter selectedIter; - gboolean isAnythingSelected = FALSE; - gboolean isFirstSelected = FALSE; - gboolean isLastSelected = FALSE; - gboolean hasConfigurationUi = FALSE; - GtkWidget *btnRemove = CappletGetGladeWidget (gipc, "btnRemove"); - GtkWidget *btnUp = CappletGetGladeWidget (gipc, "btnUp"); - GtkWidget *btnDown = CappletGetGladeWidget (gipc, "btnDown"); - GtkWidget *btnProperties = CappletGetGladeWidget (gipc, "btnProperties"); - GtkWidget *lblDescription = CappletGetGladeWidget (gipc, "lblDescription"); - - gtk_label_set_text (GTK_LABEL (lblDescription), - g_strconcat ("<small><i>", - _("No description."), - "</i></small>", NULL)); - gtk_label_set_use_markup (GTK_LABEL (lblDescription), TRUE); - - if (gtk_tree_selection_get_selected (selection, NULL, &selectedIter)) - { - int counter = gtk_tree_model_iter_n_children (model, NULL); - GtkTreePath *treePath = gtk_tree_model_get_path (model, &selectedIter); - gint *indices = gtk_tree_path_get_indices (treePath); - char *fullPath = CappletGetSelectedActivePluginPath (gipc); - const GkbdIndicatorPlugin *plugin = - gkbd_indicator_plugin_manager_get_plugin (&gipc->plugin_manager, - fullPath); - - isAnythingSelected = TRUE; - - isFirstSelected = indices[0] == 0; - isLastSelected = indices[0] == counter - 1; - - if (plugin != NULL) - { - hasConfigurationUi = - (plugin->configure_properties_callback != NULL); - gtk_label_set_text (GTK_LABEL (lblDescription), - g_strconcat ("<small><i>", - plugin-> - description, - "</i></small>", NULL)); - gtk_label_set_use_markup (GTK_LABEL (lblDescription), TRUE); + GtkWidget *activePlugins = + CappletGetGladeWidget (gipc, "activePlugins"); + GtkTreeModel *model = + gtk_tree_view_get_model (GTK_TREE_VIEW (activePlugins)); + GtkTreeIter selectedIter; + gboolean isAnythingSelected = FALSE; + gboolean isFirstSelected = FALSE; + gboolean isLastSelected = FALSE; + gboolean hasConfigurationUi = FALSE; + GtkWidget *btnRemove = CappletGetGladeWidget (gipc, "btnRemove"); + GtkWidget *btnUp = CappletGetGladeWidget (gipc, "btnUp"); + GtkWidget *btnDown = CappletGetGladeWidget (gipc, "btnDown"); + GtkWidget *btnProperties = + CappletGetGladeWidget (gipc, "btnProperties"); + GtkWidget *lblDescription = + CappletGetGladeWidget (gipc, "lblDescription"); + + gtk_label_set_text (GTK_LABEL (lblDescription), + g_strconcat ("<small><i>", + _("No description."), + "</i></small>", NULL)); + gtk_label_set_use_markup (GTK_LABEL (lblDescription), TRUE); + + if (gtk_tree_selection_get_selected + (selection, NULL, &selectedIter)) { + int counter = gtk_tree_model_iter_n_children (model, NULL); + GtkTreePath *treePath = + gtk_tree_model_get_path (model, &selectedIter); + gint *indices = gtk_tree_path_get_indices (treePath); + char *fullPath = CappletGetSelectedActivePluginPath (gipc); + const GkbdIndicatorPlugin *plugin = + gkbd_indicator_plugin_manager_get_plugin (&gipc-> + plugin_manager, + fullPath); + + isAnythingSelected = TRUE; + + isFirstSelected = indices[0] == 0; + isLastSelected = indices[0] == counter - 1; + + if (plugin != NULL) { + hasConfigurationUi = + (plugin->configure_properties_callback != + NULL); + gtk_label_set_text (GTK_LABEL (lblDescription), + g_strconcat ("<small><i>", + plugin-> + description, + "</i></small>", + NULL)); + gtk_label_set_use_markup (GTK_LABEL + (lblDescription), TRUE); + } + g_free (fullPath); + + gtk_tree_path_free (treePath); } - g_free (fullPath); - - gtk_tree_path_free (treePath); - } - gtk_widget_set_sensitive (btnRemove, isAnythingSelected); - gtk_widget_set_sensitive (btnUp, isAnythingSelected && !isFirstSelected); - gtk_widget_set_sensitive (btnDown, isAnythingSelected && !isLastSelected); - gtk_widget_set_sensitive (btnProperties, isAnythingSelected - && hasConfigurationUi); + gtk_widget_set_sensitive (btnRemove, isAnythingSelected); + gtk_widget_set_sensitive (btnUp, isAnythingSelected + && !isFirstSelected); + gtk_widget_set_sensitive (btnDown, isAnythingSelected + && !isLastSelected); + gtk_widget_set_sensitive (btnProperties, isAnythingSelected + && hasConfigurationUi); } static void -CappletPromotePlugin (GtkWidget * btnUp, GkbdIndicatorPluginsCapplet * gipc) +CappletPromotePlugin (GtkWidget * btnUp, + GkbdIndicatorPluginsCapplet * gipc) { - char *fullPath = CappletGetSelectedActivePluginPath (gipc); - if (fullPath != NULL) - { - gkbd_indicator_plugin_manager_promote_plugin (&gipc-> - plugin_manager, - gipc->applet_cfg. - enabled_plugins, - fullPath); - g_free (fullPath); - CappletFillActivePluginList (gipc); - gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); - } + char *fullPath = CappletGetSelectedActivePluginPath (gipc); + if (fullPath != NULL) { + gkbd_indicator_plugin_manager_promote_plugin (&gipc-> + plugin_manager, + gipc-> + applet_cfg. + enabled_plugins, + fullPath); + g_free (fullPath); + CappletFillActivePluginList (gipc); + gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); + } } static void CappletDemotePlugin (GtkWidget * btnUp, GkbdIndicatorPluginsCapplet * gipc) { - char *fullPath = CappletGetSelectedActivePluginPath (gipc); - if (fullPath != NULL) - { - gkbd_indicator_plugin_manager_demote_plugin (&gipc-> - plugin_manager, - gipc->applet_cfg. - enabled_plugins, fullPath); - g_free (fullPath); - CappletFillActivePluginList (gipc); - gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); - } + char *fullPath = CappletGetSelectedActivePluginPath (gipc); + if (fullPath != NULL) { + gkbd_indicator_plugin_manager_demote_plugin (&gipc-> + plugin_manager, + gipc-> + applet_cfg. + enabled_plugins, + fullPath); + g_free (fullPath); + CappletFillActivePluginList (gipc); + gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); + } } static void CappletDisablePlugin (GtkWidget * btnRemove, GkbdIndicatorPluginsCapplet * gipc) { - char *fullPath = CappletGetSelectedActivePluginPath (gipc); - if (fullPath != NULL) - { - gkbd_indicator_plugin_manager_disable_plugin (&gipc-> - plugin_manager, - &gipc-> - applet_cfg. - enabled_plugins, - fullPath); - g_free (fullPath); - CappletFillActivePluginList (gipc); - gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); - } + char *fullPath = CappletGetSelectedActivePluginPath (gipc); + if (fullPath != NULL) { + gkbd_indicator_plugin_manager_disable_plugin (&gipc-> + plugin_manager, + &gipc-> + applet_cfg. + enabled_plugins, + fullPath); + g_free (fullPath); + CappletFillActivePluginList (gipc); + gkbd_indicator_config_save_to_gconf (&gipc->applet_cfg); + } } static void CappletConfigurePlugin (GtkWidget * btnRemove, GkbdIndicatorPluginsCapplet * gipc) { - char *fullPath = CappletGetSelectedActivePluginPath (gipc); - if (fullPath != NULL) - { - gkbd_indicator_plugin_manager_configure_plugin (&gipc-> - plugin_manager, - &gipc-> - plugin_container, - fullPath, - GTK_WINDOW - (gipc->capplet)); - g_free (fullPath); - } + char *fullPath = CappletGetSelectedActivePluginPath (gipc); + if (fullPath != NULL) { + gkbd_indicator_plugin_manager_configure_plugin (&gipc-> + plugin_manager, + &gipc-> + plugin_container, + fullPath, + GTK_WINDOW + (gipc-> + capplet)); + g_free (fullPath); + } } static void CappletResponse (GtkDialog * dialog, gint response) { - if (response == GTK_RESPONSE_HELP) - { - GError *error = NULL; - gnome_help_display_on_screen ("gkbd", "gkb-indicator-applet-plugins", - gtk_widget_get_screen (GTK_WIDGET - (dialog)), &error); - return; - } - - g_main_loop_quit (loop); + if (response == GTK_RESPONSE_HELP) { + GError *error = NULL; + gnome_help_display_on_screen ("gkbd", + "gkb-indicator-applet-plugins", + gtk_widget_get_screen + (GTK_WIDGET (dialog)), + &error); + return; + } + + g_main_loop_quit (loop); } static void CappletSetup (GkbdIndicatorPluginsCapplet * gipc) { - GladeXML *data; - GtkWidget *capplet; - GtkWidget *activePlugins; - GtkTreeModel *activePluginsModel; - GtkCellRenderer *renderer = - GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); - GtkTreeViewColumn *column = - gtk_tree_view_column_new_with_attributes (NULL, renderer, - "text", 0, - NULL); - GtkTreeSelection *selection; - glade_gnome_init (); - - gtk_window_set_default_icon_name ("gkbd-indicator-plugins-capplet"); - - /* default domain! */ - data = - glade_xml_new (GLADEDIR "/gkbd-indicator-plugins.glade", - "gkbd_indicator_plugins", NULL); - gipc->capplet = capplet = - glade_xml_get_widget (data, "gkbd_indicator_plugins"); - - gtk_object_set_data (GTK_OBJECT (capplet), "gladeData", data); - g_signal_connect_swapped (GTK_OBJECT (capplet), - "destroy", G_CALLBACK (g_object_unref), data); - g_signal_connect_swapped (G_OBJECT (capplet), "unrealize", - G_CALLBACK (g_main_loop_quit), loop); - - g_signal_connect (GTK_OBJECT (capplet), - "response", G_CALLBACK (CappletResponse), NULL); - - glade_xml_signal_connect_data (data, "on_btnUp_clicked", - GTK_SIGNAL_FUNC - (CappletPromotePlugin), gipc); - glade_xml_signal_connect_data (data, - "on_btnDown_clicked", - GTK_SIGNAL_FUNC (CappletDemotePlugin), gipc); - glade_xml_signal_connect_data (data, - "on_btnAdd_clicked", - GTK_SIGNAL_FUNC (CappletEnablePlugin), gipc); - glade_xml_signal_connect_data (data, - "on_btnRemove_clicked", - GTK_SIGNAL_FUNC - (CappletDisablePlugin), gipc); - glade_xml_signal_connect_data (data, - "on_btnProperties_clicked", - GTK_SIGNAL_FUNC - (CappletConfigurePlugin), gipc); - - activePlugins = CappletGetGladeWidget (gipc, "activePlugins"); - activePluginsModel = - GTK_TREE_MODEL (gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING)); - gtk_tree_view_set_model (GTK_TREE_VIEW (activePlugins), activePluginsModel); - gtk_tree_view_append_column (GTK_TREE_VIEW (activePlugins), column); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (activePlugins)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (G_OBJECT (selection), "changed", - G_CALLBACK (CappletActivePluginsSelectionChanged), gipc); - CappletFillActivePluginList (gipc); - CappletActivePluginsSelectionChanged (selection, gipc); - gtk_widget_show_all (capplet); + GladeXML *data; + GtkWidget *capplet; + GtkWidget *activePlugins; + GtkTreeModel *activePluginsModel; + GtkCellRenderer *renderer = + GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + GtkTreeViewColumn *column = + gtk_tree_view_column_new_with_attributes (NULL, renderer, + "text", 0, + NULL); + GtkTreeSelection *selection; + glade_gnome_init (); + + gtk_window_set_default_icon_name + ("gkbd-indicator-plugins-capplet"); + + /* default domain! */ + data = + glade_xml_new (GLADEDIR "/gkbd-indicator-plugins.glade", + "gkbd_indicator_plugins", NULL); + gipc->capplet = capplet = + glade_xml_get_widget (data, "gkbd_indicator_plugins"); + + gtk_object_set_data (GTK_OBJECT (capplet), "gladeData", data); + g_signal_connect_swapped (GTK_OBJECT (capplet), + "destroy", G_CALLBACK (g_object_unref), + data); + g_signal_connect_swapped (G_OBJECT (capplet), "unrealize", + G_CALLBACK (g_main_loop_quit), loop); + + g_signal_connect (GTK_OBJECT (capplet), + "response", G_CALLBACK (CappletResponse), NULL); + + glade_xml_signal_connect_data (data, "on_btnUp_clicked", + GTK_SIGNAL_FUNC + (CappletPromotePlugin), gipc); + glade_xml_signal_connect_data (data, + "on_btnDown_clicked", + GTK_SIGNAL_FUNC + (CappletDemotePlugin), gipc); + glade_xml_signal_connect_data (data, "on_btnAdd_clicked", + GTK_SIGNAL_FUNC + (CappletEnablePlugin), gipc); + glade_xml_signal_connect_data (data, "on_btnRemove_clicked", + GTK_SIGNAL_FUNC + (CappletDisablePlugin), gipc); + glade_xml_signal_connect_data (data, "on_btnProperties_clicked", + GTK_SIGNAL_FUNC + (CappletConfigurePlugin), gipc); + + activePlugins = CappletGetGladeWidget (gipc, "activePlugins"); + activePluginsModel = + GTK_TREE_MODEL (gtk_list_store_new + (2, G_TYPE_STRING, G_TYPE_STRING)); + gtk_tree_view_set_model (GTK_TREE_VIEW (activePlugins), + activePluginsModel); + gtk_tree_view_append_column (GTK_TREE_VIEW (activePlugins), + column); + selection = + gtk_tree_view_get_selection (GTK_TREE_VIEW (activePlugins)); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + g_signal_connect (G_OBJECT (selection), "changed", + G_CALLBACK + (CappletActivePluginsSelectionChanged), gipc); + CappletFillActivePluginList (gipc); + CappletActivePluginsSelectionChanged (selection, gipc); + gtk_widget_show_all (capplet); } int main (int argc, char **argv) { - GkbdIndicatorPluginsCapplet gipc; - - GError *gconf_error = NULL; - GConfClient *confClient; - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - memset (&gipc, 0, sizeof (gipc)); - gnome_program_init ("gkbd", VERSION, - LIBGNOMEUI_MODULE, argc, argv, - GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); - if (!gconf_init (argc, argv, &gconf_error)) - { - g_warning (_("Failed to init GConf: %s\n"), gconf_error->message); - g_error_free (gconf_error); - return 1; - } - gconf_error = NULL; - /*GkbdIndicatorInstallGlibLogAppender( ); */ - gipc.engine = xkl_engine_get_instance (GDK_DISPLAY ()); - gipc.config_registry = xkl_config_registry_get_instance (gipc.engine); + GkbdIndicatorPluginsCapplet gipc; + + GError *gconf_error = NULL; + GConfClient *confClient; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + memset (&gipc, 0, sizeof (gipc)); + gnome_program_init ("gkbd", VERSION, + LIBGNOMEUI_MODULE, argc, argv, + GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); + if (!gconf_init (argc, argv, &gconf_error)) { + g_warning (_("Failed to init GConf: %s\n"), + gconf_error->message); + g_error_free (gconf_error); + return 1; + } + gconf_error = NULL; + /*GkbdIndicatorInstallGlibLogAppender( ); */ + gipc.engine = xkl_engine_get_instance (GDK_DISPLAY ()); + gipc.config_registry = + xkl_config_registry_get_instance (gipc.engine); - confClient = gconf_client_get_default (); - gkbd_indicator_plugin_container_init (&gipc.plugin_container, confClient); - g_object_unref (confClient); + confClient = gconf_client_get_default (); + gkbd_indicator_plugin_container_init (&gipc.plugin_container, + confClient); + g_object_unref (confClient); - gkbd_keyboard_config_init (&gipc.kbd_cfg, confClient, gipc.engine); - gkbd_keyboard_config_init (&initialSysKbdConfig, confClient, gipc.engine); + gkbd_keyboard_config_init (&gipc.kbd_cfg, confClient, gipc.engine); + gkbd_keyboard_config_init (&initialSysKbdConfig, confClient, + gipc.engine); - gkbd_indicator_config_init (&gipc.applet_cfg, confClient, gipc.engine); + gkbd_indicator_config_init (&gipc.applet_cfg, confClient, + gipc.engine); - gkbd_indicator_plugin_manager_init (&gipc.plugin_manager); + gkbd_indicator_plugin_manager_init (&gipc.plugin_manager); - gkbd_keyboard_config_load_from_x_initial (&initialSysKbdConfig, NULL); - gkbd_keyboard_config_load_from_gconf (&gipc.kbd_cfg, &initialSysKbdConfig); + gkbd_keyboard_config_load_from_x_initial (&initialSysKbdConfig, + NULL); + gkbd_keyboard_config_load_from_gconf (&gipc.kbd_cfg, + &initialSysKbdConfig); - gkbd_indicator_config_load_from_gconf (&gipc.applet_cfg); + gkbd_indicator_config_load_from_gconf (&gipc.applet_cfg); - loop = g_main_loop_new (NULL, TRUE); + loop = g_main_loop_new (NULL, TRUE); - CappletSetup (&gipc); + CappletSetup (&gipc); - g_main_loop_run (loop); + g_main_loop_run (loop); - gkbd_indicator_plugin_manager_term (&gipc.plugin_manager); + gkbd_indicator_plugin_manager_term (&gipc.plugin_manager); - gkbd_indicator_config_term (&gipc.applet_cfg); + gkbd_indicator_config_term (&gipc.applet_cfg); - gkbd_keyboard_config_term (&gipc.kbd_cfg); - gkbd_keyboard_config_term (&initialSysKbdConfig); + gkbd_keyboard_config_term (&gipc.kbd_cfg); + gkbd_keyboard_config_term (&initialSysKbdConfig); - gkbd_indicator_plugin_container_term (&gipc.plugin_container); - g_object_unref (G_OBJECT (gipc.config_registry)); - g_object_unref (G_OBJECT (gipc.engine)); - return 0; + gkbd_indicator_plugin_container_term (&gipc.plugin_container); + g_object_unref (G_OBJECT (gipc.config_registry)); + g_object_unref (G_OBJECT (gipc.engine)); + return 0; } /* functions just for plugins - otherwise ldd is not happy */ void -gkbd_indicator_plugin_container_reinit_ui (GkbdIndicatorPluginContainer * pc) +gkbd_indicator_plugin_container_reinit_ui (GkbdIndicatorPluginContainer * + pc) { } -gchar ** -gkbd_indicator_plugin_load_localized_group_names (GkbdIndicatorPluginContainer - * pc) -{ - return - gkbd_desktop_config_load_group_descriptions_utf8 (& - (((GkbdIndicatorPluginsCapplet *) pc)->cfg), (((GkbdIndicatorPluginsCapplet *) pc)->config_registry)); +gchar **gkbd_indicator_plugin_load_localized_group_names + (GkbdIndicatorPluginContainer * pc) { + GkbdDesktopConfig *config = + &((GkbdIndicatorPluginsCapplet *) pc)->cfg; + XklConfigRegistry *config_registry = + ((GkbdIndicatorPluginsCapplet *) pc)->config_registry; + + int i; + const gchar **native_names = + xkl_engine_get_groups_names (config->engine); + guint total_groups = xkl_engine_get_num_groups (config->engine); + guint total_layouts; + gchar **rv = g_new0 (char *, total_groups + 1); + gchar **current_descr = rv; + + if ((xkl_engine_get_features (config->engine) & + XKLF_MULTIPLE_LAYOUTS_SUPPORTED) + && config->layout_names_as_group_names) { + XklConfigRec *xkl_config = xkl_config_rec_new (); + if (xkl_config_rec_get_from_server + (xkl_config, config->engine)) { + gchar **sgn = NULL; + gchar **fgn = NULL; + gkbd_desktop_config_load_group_descriptions + (config, config_registry, + (const gchar **) xkl_config->layouts, + (const gchar **) xkl_config->variants, &sgn, + &fgn); + g_strfreev (sgn); + rv = fgn; + } + g_object_unref (G_OBJECT (xkl_config)); + /* Worst case - multiple layous - but SOME of them are multigrouped :((( + * We cannot do much - just add empty descriptions. + * The UI is going to be messy. + * Canadian layouts are famous for this sh.t. */ + total_layouts = g_strv_length (rv); + if (total_layouts != total_groups) { + xkl_debug (0, + "The mismatch between " + "the number of groups: %d and number of layouts: %d\n", + total_groups, total_layouts); + current_descr = rv + total_layouts; + for (i = total_groups - total_layouts; --i >= 0;) + *current_descr++ = g_strdup (""); + } + } + total_layouts = g_strv_length (rv); + if (!total_layouts) + for (i = total_groups; --i >= 0;) + *current_descr++ = g_strdup (*native_names++); + + return rv; } diff --git a/capplet/gkbd-indicator-plugins-capplet.h b/capplet/gkbd-indicator-plugins-capplet.h index 4f622c2..dd37817 100644 --- a/capplet/gkbd-indicator-plugins-capplet.h +++ b/capplet/gkbd-indicator-plugins-capplet.h @@ -31,17 +31,16 @@ #include "libgnomekbd/gkbd-indicator-plugin-manager.h" #include "libgnomekbd/gkbd-util.h" -typedef struct _GkbdIndicatorPluginsCapplet -{ - GkbdIndicatorPluginContainer plugin_container; - GkbdDesktopConfig cfg; - GkbdIndicatorConfig applet_cfg; - GkbdKeyboardConfig kbd_cfg; - GkbdIndicatorPluginManager plugin_manager; - XklEngine *engine; - XklConfigRegistry *config_registry; +typedef struct _GkbdIndicatorPluginsCapplet { + GkbdIndicatorPluginContainer plugin_container; + GkbdDesktopConfig cfg; + GkbdIndicatorConfig applet_cfg; + GkbdKeyboardConfig kbd_cfg; + GkbdIndicatorPluginManager plugin_manager; + XklEngine *engine; + XklConfigRegistry *config_registry; - GtkWidget *capplet; + GtkWidget *capplet; } GkbdIndicatorPluginsCapplet; #define NAME_COLUMN 0 @@ -53,7 +52,8 @@ typedef struct _GkbdIndicatorPluginsCapplet "gladeData" ) ), \ name ) -extern void CappletFillActivePluginList (GkbdIndicatorPluginsCapplet * gipc); +extern void CappletFillActivePluginList (GkbdIndicatorPluginsCapplet * + gipc); extern char *CappletGetSelectedPluginPath (GtkTreeView * plugins_list, GkbdIndicatorPluginsCapplet * diff --git a/configure.in b/configure.in index b87417d..b230b4b 100644 --- a/configure.in +++ b/configure.in @@ -1,10 +1,10 @@ dnl *************************************************************************** dnl *** configure.in for libgnomekbd *** dnl *************************************************************************** -AC_INIT(libgnomekbd, 2.20.0, [http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomekbd]) +AC_INIT(libgnomekbd, 2.21.1, [http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomekbd]) AC_PREREQ(2.59) -VERSION_INFO=1:0:0 +VERSION_INFO=2:0:0 AC_SUBST(VERSION_INFO) AM_CONFIG_HEADER(config.h) @@ -22,7 +22,7 @@ GTK_REQUIRED=2.10.3 LIBGLADE_REQUIRED=2.6.0 LIBGNOME_REQUIRED=2.16.0 LIBGNOMEUI_REQUIRED=2.16.0 -LIBXKLAVIER_REQUIRED=2.91 +LIBXKLAVIER_REQUIRED=3.2 AC_SUBST([DBUS_REQUIRED]) AC_SUBST([DBUS_GLIB_REQUIRED]) diff --git a/libgnomekbd/Makefile.am b/libgnomekbd/Makefile.am index db6dc49..83cb5ea 100644 --- a/libgnomekbd/Makefile.am +++ b/libgnomekbd/Makefile.am @@ -34,7 +34,6 @@ libgnomekbdui_la_LDFLAGS = $(common_LDFLAGS) \ -lgnomekbd libgnomekbd_la_SOURCES = \ - gkbd-config-registry.c \ gkbd-desktop-config.c \ gkbd-keyboard-config.c \ gkbd-util.c @@ -49,8 +48,6 @@ libgnomekbdui_la_SOURCES = \ BUILT_SOURCES = gkbd-indicator-marshal.c \ gkbd-indicator-marshal.h \ - gkbd-config-registry-server.h \ - gkbd-config-registry-client.h \ gkbd-keyboard-drawing-marshal.c \ gkbd-keyboard-drawing-marshal.h @@ -60,8 +57,6 @@ gnomekbdincdir = $(includedir)/libgnomekbd gnomekbdinc_HEADERS = \ gkbd-desktop-config.h \ gkbd-keyboard-config.h \ - gkbd-config-registry-client.h \ - gkbd-config-registry.h \ gkbd-indicator.h \ gkbd-indicator-config.h \ gkbd-indicator-plugin.h \ @@ -74,12 +69,10 @@ gnomekbdinc_HEADERS = \ noinst_HEADERS = gkbd-indicator-plugin-manager.h \ $(extra_nih) \ - gkbd-config-private.h \ - gkbd-config-registry-server.h + gkbd-config-private.h EXTRA_DIST = gkbd-indicator-marshal.list \ gkbd-keyboard-drawing-marshal.list \ - gkbd-config-registry.xml \ $(glade_DATA) \ $(schema_in_files) @@ -91,12 +84,6 @@ gkbd-indicator-marshal.h: gkbd-indicator-marshal.list gkbd-indicator-marshal.c: gkbd-indicator-marshal.h $(GLIB_GENMARSHAL) --prefix=gkbd_indicator $(srcdir)/gkbd-indicator-marshal.list --body > $@ -gkbd-config-registry-server.h: gkbd-config-registry.xml - dbus-binding-tool --prefix=gkbd_config_registry --mode=glib-server $< > $@ - -gkbd-config-registry-client.h: gkbd-config-registry.xml - dbus-binding-tool --prefix=gkbd_config_registry --mode=glib-client $< > $@ - gkbd-keyboard-drawing-marshal.h: gkbd-keyboard-drawing-marshal.list ( $(GLIB_GENMARSHAL) --prefix=gkbd_keyboard_drawing $(srcdir)/gkbd-keyboard-drawing-marshal.list \ --header > gkbd-keyboard-drawing-marshal.tmp \ diff --git a/libgnomekbd/gkbd-config-registry.c b/libgnomekbd/gkbd-config-registry.c deleted file mode 100644 index 97cda3f..0000000 --- a/libgnomekbd/gkbd-config-registry.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <X11/Xlib.h> - -#include <gkbd-config-registry.h> -#include <gkbd-config-registry-server.h> -#include <gkbd-keyboard-config.h> - -static GObjectClass *parent_class = NULL; - -gboolean - gkbd_config_registry_get_descriptions_as_utf8 - (GkbdConfigRegistry * registry, - gchar ** layout_ids, - gchar ** variant_ids, - gchar *** short_layout_descriptions, - gchar *** long_layout_descriptions, - gchar *** short_variant_descriptions, - gchar *** long_variant_descriptions, GError ** error) { - char **pl, **pv; - guint total_layouts; - gchar **sld, **lld, **svd, **lvd; - XklConfigItem *item = xkl_config_item_new (); - - if (!registry->registry) { - registry->registry = - xkl_config_registry_get_instance (registry->engine); - - xkl_config_registry_load (registry->registry); - } - - if (! - (xkl_engine_get_features (registry->engine) & - XKLF_MULTIPLE_LAYOUTS_SUPPORTED)) - return FALSE; - - pl = layout_ids; - pv = variant_ids; - total_layouts = g_strv_length (layout_ids); - sld = *short_layout_descriptions = - g_new0 (char *, total_layouts + 1); - lld = *long_layout_descriptions = - g_new0 (char *, total_layouts + 1); - svd = *short_variant_descriptions = - g_new0 (char *, total_layouts + 1); - lvd = *long_variant_descriptions = - g_new0 (char *, total_layouts + 1); - - while (pl != NULL && *pl != NULL) { - - xkl_debug (100, "ids: [%s][%s]\n", *pl, - pv == NULL ? NULL : *pv); - - g_snprintf (item->name, sizeof item->name, "%s", *pl); - if (xkl_config_registry_find_layout - (registry->registry, item)) { - *sld = g_strdup (item->short_description); - *lld = g_strdup (item->description); - } else { - *sld = g_strdup (""); - *lld = g_strdup (""); - } - - if (*pv != NULL) { - g_snprintf (item->name, sizeof item->name, "%s", - *pv); - if (xkl_config_registry_find_variant - (registry->registry, *pl, item)) { - *svd = g_strdup (item->short_description); - *lvd = g_strdup (item->description); - } else { - *svd = g_strdup (""); - *lvd = g_strdup (""); - } - } else { - *svd = g_strdup (""); - *lvd = g_strdup (""); - } - - xkl_debug (100, "description: [%s][%s][%s][%s]\n", - *sld, *lld, *svd, *lvd); - sld++; - lld++; - svd++; - lvd++; - - pl++; - - if (*pv != NULL) - pv++; - } - - g_object_unref (item); - return TRUE; -} - -G_DEFINE_TYPE (GkbdConfigRegistry, gkbd_config_registry, G_TYPE_OBJECT) -static void -finalize (GObject * object) -{ - GkbdConfigRegistry *registry; - - registry = GKBD_CONFIG_REGISTRY (object); - if (registry->registry == NULL) { - return; - } - - g_object_unref (registry->registry); - registry->registry = NULL; - - g_object_unref (registry->engine); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -gkbd_config_registry_class_init (GkbdConfigRegistryClass * klass) -{ - GError *error = NULL; - GObjectClass *object_class; - - /* Init the DBus connection, per-klass */ - klass->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (klass->connection == NULL) { - g_warning ("Unable to connect to dbus: %s", - error->message); - g_error_free (error); - return; - } - - dbus_g_object_type_install_info (GKBD_CONFIG_TYPE_REGISTRY, - &dbus_glib_gkbd_config_registry_object_info); - - object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = finalize; - - parent_class = g_type_class_peek_parent (klass); -} - -static void -gkbd_config_registry_init (GkbdConfigRegistry * registry) -{ - GError *error = NULL; - DBusGProxy *driver_proxy; - GkbdConfigRegistryClass *klass = - GKBD_CONFIG_REGISTRY_GET_CLASS (registry); - unsigned request_ret; - - if (klass->connection == NULL) { - g_warning ("Not connected to dbus, will not register the object"); - return; - } - - /* Register DBUS path */ - dbus_g_connection_register_g_object (klass->connection, - "/org/gnome/GkbdConfigRegistry", - G_OBJECT (registry)); - - /* Register the service name, the constant here are defined in dbus-glib-bindings.h */ - driver_proxy = dbus_g_proxy_new_for_name (klass->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (driver_proxy != NULL) { - if (!org_freedesktop_DBus_request_name - (driver_proxy, "org.gnome.GkbdConfigRegistry", 0, - &request_ret, &error)) { - g_warning ("Unable to register service: %s", - error->message); - g_error_free (error); - } - g_object_unref (driver_proxy); - } else - g_critical ("Could not create DBUS proxy"); - - /* Init libxklavier stuff */ - registry->engine = xkl_engine_get_instance (XOpenDisplay (NULL)); - /* Lazy initialization */ - registry->registry = NULL; -} diff --git a/libgnomekbd/gkbd-config-registry.h b/libgnomekbd/gkbd-config-registry.h deleted file mode 100644 index d958090..0000000 --- a/libgnomekbd/gkbd-config-registry.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GKBD_CONFIG_REGISTRY_H__ -#define __GKBD_CONFIG_REGISTRY_H__ - -#include <dbus/dbus-glib-bindings.h> -#include <libxklavier/xklavier.h> - -typedef struct GkbdConfigRegistry GkbdConfigRegistry; -typedef struct GkbdConfigRegistryClass GkbdConfigRegistryClass; - -struct GkbdConfigRegistry { - GObject parent; - - XklEngine *engine; - XklConfigRegistry *registry; -}; - -struct GkbdConfigRegistryClass { - GObjectClass parent; - DBusGConnection *connection; -}; - -#define GKBD_CONFIG_TYPE_REGISTRY (gkbd_config_registry_get_type ()) -#define GKBD_CONFIG_REGISTRY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GKBD_CONFIG_TYPE_REGISTRY, GkbdConfigRegistry)) -#define GKBD_CONFIG_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GKBD_CONFIG_TYPE_REGISTRY, GkbdConfigRegistryClass)) -#define GKBD_IS_CONFIG_REGISTRY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GKBD_CONFIG_TYPE_REGISTRY)) -#define GKBD_IS_CONFIG_REGISTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GKBD_CONFIG_TYPE_REGISTRY)) -#define GKBD_CONFIG_REGISTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GKBD_CONFIG_TYPE_REGISTRY, GkbdConfigRegistryClass)) - - -/** - * DBUS server - */ - -extern GType gkbd_config_registry_get_type (void); - -extern gboolean - gkbd_config_registry_get_descriptions_as_utf8 - (GkbdConfigRegistry * registry, - gchar ** layout_ids, - gchar ** variant_ids, - gchar *** short_layout_descriptions, - gchar *** long_layout_descriptions, - gchar *** short_variant_descriptions, - gchar *** long_variant_descriptions, GError ** error); - -#endif diff --git a/libgnomekbd/gkbd-config-registry.xml b/libgnomekbd/gkbd-config-registry.xml deleted file mode 100644 index 73b6404..0000000 --- a/libgnomekbd/gkbd-config-registry.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<node name="/org/gnome/GkbdConfigRegistry"> - <interface name="org.gnome.GkbdConfigRegistry"> - <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="gkbd_config_registry"/> - <method name="GetDescriptionsAsUtf8"> - <arg type="as" name="layoutIds" direction="in" /> - <arg type="as" name="variantIds" direction="in" /> - <arg type="as" name="shortLayoutDescriptions" direction="out" /> - <arg type="as" name="longLayoutDescriptions" direction="out" /> - <arg type="as" name="shortVariantDescriptions" direction="out" /> - <arg type="as" name="longVariantDescriptions" direction="out" /> - </method> - <!-- Add more methods/signals if you want --> - </interface> -</node> diff --git a/libgnomekbd/gkbd-desktop-config.c b/libgnomekbd/gkbd-desktop-config.c index ce33f12..3fac8d3 100644 --- a/libgnomekbd/gkbd-desktop-config.c +++ b/libgnomekbd/gkbd-desktop-config.c @@ -29,8 +29,6 @@ #include <gkbd-desktop-config.h> #include <gkbd-config-private.h> -#include <gkbd-config-registry-client.h> - /** * GkbdDesktopConfig */ @@ -51,42 +49,82 @@ const gchar GKBD_DESKTOP_CONFIG_KEY_LAYOUT_NAMES_AS_GROUP_NAMES[] */ static gboolean -gkbd_desktop_config_get_remote_lv_descriptions_utf8 (const gchar ** lids, - const gchar ** vids, - gchar *** sld, - gchar *** lld, - gchar *** svd, - gchar *** lvd) -{ - DBusGProxy *proxy; - DBusGConnection *connection; - GError *error = NULL; - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) { - g_warning ("Unable to connect to dbus: %s\n", - error->message); - g_error_free (error); - /* Basically here, there is a problem, since there is no dbus :) */ - return False; - } + gkbd_desktop_config_get_lv_descriptions + (GkbdDesktopConfig * config, + XklConfigRegistry * registry, + const gchar ** layout_ids, + const gchar ** variant_ids, + gchar *** short_layout_descriptions, + gchar *** long_layout_descriptions, + gchar *** short_variant_descriptions, + gchar *** long_variant_descriptions) { + const gchar **pl, **pv; + guint total_layouts; + gchar **sld, **lld, **svd, **lvd; + XklConfigItem *item = xkl_config_item_new (); + + if (! + (xkl_engine_get_features (config->engine) & + XKLF_MULTIPLE_LAYOUTS_SUPPORTED)) + return FALSE; + + pl = layout_ids; + pv = variant_ids; + total_layouts = g_strv_length ((char **) layout_ids); + sld = *short_layout_descriptions = + g_new0 (char *, total_layouts + 1); + lld = *long_layout_descriptions = + g_new0 (char *, total_layouts + 1); + svd = *short_variant_descriptions = + g_new0 (char *, total_layouts + 1); + lvd = *long_variant_descriptions = + g_new0 (char *, total_layouts + 1); + + while (pl != NULL && *pl != NULL) { + + xkl_debug (100, "ids: [%s][%s]\n", *pl, + pv == NULL ? NULL : *pv); + + g_snprintf (item->name, sizeof item->name, "%s", *pl); + if (xkl_config_registry_find_layout (registry, item)) { + *sld = g_strdup (item->short_description); + *lld = g_strdup (item->description); + } else { + *sld = g_strdup (""); + *lld = g_strdup (""); + } -/* This won't trigger activation! */ - proxy = dbus_g_proxy_new_for_name (connection, - "org.gnome.GkbdConfigRegistry", - "/org/gnome/GkbdConfigRegistry", - "org.gnome.GkbdConfigRegistry"); - -/* The method call will trigger activation, more on that later */ - if (!org_gnome_GkbdConfigRegistry_get_descriptions_as_utf8 - (proxy, lids, vids, sld, lld, svd, lvd, &error)) { - /* Method failed, the GError is set, let's warn everyone */ - g_warning ("Woops remote method failed: %s", - error->message); - g_error_free (error); - return False; + if (*pv != NULL) { + g_snprintf (item->name, sizeof item->name, "%s", + *pv); + if (xkl_config_registry_find_variant + (registry, *pl, item)) { + *svd = g_strdup (item->short_description); + *lvd = g_strdup (item->description); + } else { + *svd = g_strdup (""); + *lvd = g_strdup (""); + } + } else { + *svd = g_strdup (""); + *lvd = g_strdup (""); + } + + xkl_debug (100, "description: [%s][%s][%s][%s]\n", + *sld, *lld, *svd, *lvd); + sld++; + lld++; + svd++; + lvd++; + + pl++; + + if (*pv != NULL) + pv++; } - return True; + + g_object_unref (item); + return TRUE; } void @@ -299,24 +337,26 @@ gkbd_desktop_config_stop_listen (GkbdDesktopConfig * config) } gboolean -gkbd_desktop_config_load_remote_group_descriptions_utf8 (GkbdDesktopConfig - * config, - const gchar ** - layout_ids, - const gchar ** - variant_ids, - gchar *** - short_group_names, - gchar *** - full_group_names) +gkbd_desktop_config_load_group_descriptions (GkbdDesktopConfig + * config, + XklConfigRegistry * + registry, + const gchar ** + layout_ids, + const gchar ** + variant_ids, + gchar *** + short_group_names, + gchar *** full_group_names) { gchar **sld, **lld, **svd, **lvd; gchar **psld, **plld, **plvd; gchar **psgn, **pfgn; gint total_descriptions; - if (!gkbd_desktop_config_get_remote_lv_descriptions_utf8 - (layout_ids, variant_ids, &sld, &lld, &svd, &lvd)) { + if (!gkbd_desktop_config_get_lv_descriptions + (config, registry, layout_ids, variant_ids, &sld, &lld, &svd, + &lvd)) { return False; } @@ -343,66 +383,3 @@ gkbd_desktop_config_load_remote_group_descriptions_utf8 (GkbdDesktopConfig return True; } -gchar ** -gkbd_desktop_config_load_group_descriptions_utf8 (GkbdDesktopConfig * - config, - XklConfigRegistry * - config_registry) -{ - int i; - const gchar **native_names = - xkl_engine_get_groups_names (config->engine); - guint total_groups = xkl_engine_get_num_groups (config->engine); - guint total_layouts; - gchar **rv = g_new0 (char *, total_groups + 1); - gchar **current_descr = rv; - - if ((xkl_engine_get_features (config->engine) & - XKLF_MULTIPLE_LAYOUTS_SUPPORTED) - && config->layout_names_as_group_names) { - XklConfigRec *xkl_config = xkl_config_rec_new (); - if (xkl_config_rec_get_from_server - (xkl_config, config->engine)) { - char **pl = xkl_config->layouts; - char **pv = xkl_config->variants; - i = total_groups; - while (pl != NULL && *pl != NULL && i >= 0) { - char *ls_descr; - char *l_descr; - char *vs_descr; - char *v_descr; - if (gkbd_keyboard_config_get_lv_descriptions (config_registry, *pl++, *pv++, &ls_descr, &l_descr, &vs_descr, &v_descr)) { - char *name_utf = - g_locale_to_utf8 - (gkbd_keyboard_config_format_full_layout - (l_descr, v_descr), -1, NULL, - NULL, NULL); - *current_descr++ = name_utf; - } else { - *current_descr++ = g_strdup (""); - } - } - } - g_object_unref (G_OBJECT (xkl_config)); - /* Worst case - multiple layous - but SOME of them are multigrouped :((( - * We cannot do much - just add empty descriptions. - * The UI is going to be messy. - * Canadian layouts are famous for this sh.t. */ - total_layouts = g_strv_length (rv); - if (total_layouts != total_groups) { - xkl_debug (0, - "The mismatch between " - "the number of groups: %d and number of layouts: %d\n", - total_groups, total_layouts); - current_descr = rv + total_layouts; - for (i = total_groups - total_layouts; --i >= 0;) - *current_descr++ = g_strdup (""); - } - } - total_layouts = g_strv_length (rv); - if (!total_layouts) - for (i = total_groups; --i >= 0;) - *current_descr++ = g_strdup (*native_names++); - - return rv; -} diff --git a/libgnomekbd/gkbd-desktop-config.h b/libgnomekbd/gkbd-desktop-config.h index 11eb91d..a8ab6e2 100644 --- a/libgnomekbd/gkbd-desktop-config.h +++ b/libgnomekbd/gkbd-desktop-config.h @@ -65,27 +65,18 @@ extern void gkbd_desktop_config_save_to_gconf (GkbdDesktopConfig * config); extern gboolean gkbd_desktop_config_activate (GkbdDesktopConfig * config); -/* Affected by XKB and XKB/GConf configuration */ -extern gchar - ** -gkbd_desktop_config_load_group_descriptions_utf8 (GkbdDesktopConfig * - config, - XklConfigRegistry * - config_registry); - - -/* Using DBUS */ extern gboolean -gkbd_desktop_config_load_remote_group_descriptions_utf8 (GkbdDesktopConfig - * config, - const gchar ** - layout_ids, - const gchar ** - variant_ids, - gchar *** - short_group_names, - gchar *** - full_group_names); +gkbd_desktop_config_load_group_descriptions (GkbdDesktopConfig + * config, + XklConfigRegistry * + registry, + const gchar ** + layout_ids, + const gchar ** + variant_ids, + gchar *** + short_group_names, + gchar *** full_group_names); extern void gkbd_desktop_config_lock_next_group (GkbdDesktopConfig * config); diff --git a/libgnomekbd/gkbd-indicator-config.c b/libgnomekbd/gkbd-indicator-config.c index c03202b..8f784ec 100644 --- a/libgnomekbd/gkbd-indicator-config.c +++ b/libgnomekbd/gkbd-indicator-config.c @@ -32,8 +32,6 @@ #include <gkbd-config-private.h> -#include <gkbd-config-registry-client.h> - /** * GkbdIndicatorConfig */ diff --git a/libgnomekbd/gkbd-indicator.c b/libgnomekbd/gkbd-indicator.c index 323f5d8..f3ded9c 100644 --- a/libgnomekbd/gkbd-indicator.c +++ b/libgnomekbd/gkbd-indicator.c @@ -31,10 +31,9 @@ #include <gkbd-indicator-plugin-manager.h> -#include <gkbd-config-registry-client.h> - typedef struct _gki_globals { XklEngine *engine; + XklConfigRegistry *registry; GkbdDesktopConfig cfg; GkbdIndicatorConfig ind_cfg; @@ -418,8 +417,8 @@ static void gkbd_indicator_load_group_names (const gchar ** layout_ids, const gchar ** variant_ids) { - if (!gkbd_desktop_config_load_remote_group_descriptions_utf8 - (&globals.cfg, layout_ids, variant_ids, + if (!gkbd_desktop_config_load_group_descriptions + (&globals.cfg, globals.registry, layout_ids, variant_ids, &globals.short_group_names, &globals.full_group_names)) { /* We just populate no short names (remain NULL) - * full names are going to be used anyway */ @@ -431,7 +430,7 @@ gkbd_indicator_load_group_names (const gchar ** layout_ids, if (xkl_engine_get_features (globals.engine) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED) { GSList *lst = globals.kbd_cfg.layouts_variants; - for (i = 0; lst; lst = lst->next,i++) { + for (i = 0; lst; lst = lst->next, i++) { globals.full_group_names[i] = g_strdup ((char *) lst->data); } @@ -675,6 +674,8 @@ gkbd_indicator_global_term (void) gkbd_indicator_plugin_container_term (&globals.plugin_container); + g_object_unref (G_OBJECT (globals.registry)); + globals.registry = NULL; g_object_unref (G_OBJECT (globals.engine)); globals.engine = NULL; xkl_debug (100, "*** Terminated globals *** \n"); @@ -719,6 +720,11 @@ gkbd_indicator_global_init (void) return; } + globals.registry = + xkl_config_registry_get_instance (globals.engine); + + xkl_config_registry_load (globals.registry); + gconf_client = gconf_client_get_default (); g_signal_connect (globals.engine, "X-state-changed", diff --git a/libgnomekbd/gkbd-keyboard-config.c b/libgnomekbd/gkbd-keyboard-config.c index 923d4ef..295299a 100644 --- a/libgnomekbd/gkbd-keyboard-config.c +++ b/libgnomekbd/gkbd-keyboard-config.c @@ -29,8 +29,6 @@ #include <gkbd-keyboard-config.h> #include <gkbd-config-private.h> -#include <gkbd-config-registry-client.h> - /** * GkbdKeyboardConfig */ diff --git a/test/Makefile.am b/test/Makefile.am index d79e0ad..cf543b9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,16 +1,5 @@ noinst_PROGRAMS = gkbd-indicator-test \ - gkbd-keyboard-drawing-test \ - gkbd-config-registry-server - -gkbd_config_registry_server_CFLAGS= \ - $(WARN_CFLAGS) -I$(top_srcdir) -Wall -Werror \ - $(DBUS_CFLAGS) \ - $(LIBXKLAVIER_CFLAGS) - -gkbd_config_registry_server_LDFLAGS= \ - $(DBUS_LIBS) \ - $(LIBXKLAVIER_LIBS) \ - $(top_builddir)/libgnomekbd/libgnomekbd.la + gkbd-keyboard-drawing-test gkbd_indicator_test_CFLAGS= \ $(WARN_CFLAGS) -I$(top_srcdir) -Wall -Werror \ @@ -40,5 +29,3 @@ gkbd_keyboard_drawing_test_LDFLAGS= \ $(LIBXKLAVIER_LIBS) \ $(top_builddir)/libgnomekbd/libgnomekbd.la \ $(top_builddir)/libgnomekbd/libgnomekbdui.la - -EXTRA_DIST = gkbd-config-registry-client.sh diff --git a/test/gkbd-config-registry-client.sh b/test/gkbd-config-registry-client.sh deleted file mode 100755 index 6b98fc2..0000000 --- a/test/gkbd-config-registry-client.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -# -# $Id$ -# -# This tiny script is expected to test the available keyboard config registry, -# getting descriptions out of it -# - -objname=GkbdConfigRegistry -method=GetDescriptionsAsUtf8 - -# Old: -#objname=KeyboardConfigRegistry -#method=GetCurrentDescriptionsAsUtf8 - -dbus-send --session \ - --dest=org.gnome.$objname \ - --type=method_call \ - --print-reply \ - --reply-timeout=20000 \ - /org/gnome/$objname \ - org.gnome.$objname.$method \ - array:string:"us","ru","fr","de","il" \ - array:string:"basic","winkeys","","deadkeys","dummy" diff --git a/test/gkbd-config-registry-server.c b/test/gkbd-config-registry-server.c deleted file mode 100644 index b4c0fac..0000000 --- a/test/gkbd-config-registry-server.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <stdio.h> -#include <X11/Xlib.h> -#include <libxklavier/xklavier.h> -#include <dbus/dbus-glib-bindings.h> - -#ifdef HAVE_SETLOCALE -# include <locale.h> -#endif - -#include "libgnomekbd/gkbd-config-registry.h" - -static GMainLoop *loop; - -int -main () -{ - GkbdConfigRegistry *reg; - - g_type_init_with_debug_flags (G_TYPE_DEBUG_OBJECTS | - G_TYPE_DEBUG_SIGNALS); - -#ifdef HAVE_SETLOCALE - setlocale(LC_ALL, ""); -#endif - - reg = GKBD_CONFIG_REGISTRY (g_object_new - (gkbd_config_registry_get_type - (), NULL)); - - loop = g_main_loop_new (NULL, FALSE); - - g_main_loop_run (loop); - - g_object_unref (reg); - - return 0; -} |