static void add_remove_pages (void) { gint lists = aud_playlist_count (); gint pages = gtk_notebook_get_n_pages ((GtkNotebook *) notebook); /* scan through existing treeviews */ for (gint i = 0; i < pages; ) { GtkWidget * page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, i); GtkWidget * tree = g_object_get_data ((GObject *) page, "treeview"); gint tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id")); /* do we have an orphaned treeview? */ if (aud_playlist_by_unique_id (tree_id) < 0) { g_signal_handlers_block_by_func (notebook, (void *) tab_changed, NULL); gtk_notebook_remove_page ((GtkNotebook *) notebook, i); g_signal_handlers_unblock_by_func (notebook, (void *) tab_changed, NULL); pages --; continue; } /* do we have the right treeview? */ gint list_id = aud_playlist_get_unique_id (i); if (tree_id == list_id) { ui_playlist_widget_set_playlist (tree, i); i ++; continue; } /* look for the right treeview */ gint found = FALSE; for (gint j = i + 1; j < pages; j ++) { page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, j); tree = g_object_get_data ((GObject *) page, "treeview"); tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id")); /* found it? move it to the right place */ if (tree_id == list_id) { g_signal_handlers_block_by_func (notebook, (void *) tab_reordered, NULL); gtk_notebook_reorder_child ((GtkNotebook *) notebook, page, i); g_signal_handlers_unblock_by_func (notebook, (void *) tab_reordered, NULL); found = TRUE; break; } } /* didn't find it? create it */ if (! found) { ui_playlist_notebook_create_tab (i); pages ++; continue; } } /* create new treeviews */ while (pages < lists) { ui_playlist_notebook_create_tab (pages); pages ++; } }
void setup_system (GtkBuilder *dialog) { gchar *language; GDBusConnection *bus; GtkWidget *button; localed_permission = polkit_permission_new_sync ("org.freedesktop.locale1.set-locale", NULL, NULL, NULL); if (localed_permission == NULL) { GtkWidget *tab_widget, *notebook; int num; tab_widget = WID ("table3"); notebook = WID ("region_notebook"); num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), tab_widget); gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), num); return; } g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, localed_permission); g_signal_connect (localed_permission, "notify", G_CALLBACK (on_permission_changed), dialog); on_permission_changed (localed_permission, NULL, dialog); button = WID ("copy_settings_button"); g_signal_connect (button, "clicked", G_CALLBACK (copy_settings), dialog); locale_settings = g_settings_new ("org.gnome.system.locale"); g_signal_connect (locale_settings, "changed::region", G_CALLBACK (locale_settings_changed), dialog); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, locale_settings); xkb_settings = g_settings_new (GKBD_KEYBOARD_SCHEMA); g_signal_connect (xkb_settings, "changed::layouts", G_CALLBACK (xkb_settings_changed), dialog); g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_object_unref, xkb_settings); /* Display user settings */ language = cc_common_language_get_current_language (); system_update_language (dialog, language); g_free (language); locale_settings_changed (locale_settings, "region", dialog); xkb_settings_changed (xkb_settings, "layouts", dialog); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL); g_dbus_proxy_new (bus, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.locale1", "/org/freedesktop/locale1", "org.freedesktop.locale1", NULL, (GAsyncReadyCallback) localed_proxy_ready, dialog); g_object_unref (bus); }
/* Fill project selection page */ static gboolean npw_druid_fill_selection_page (NPWDruid* druid, GFile *templates) { gchar* dir; const gchar * const * sys_dir; /* Remove all previous data */ gtk_notebook_remove_page(druid->project_book, 0); npw_header_list_free (druid->header_list); anjuta_autogen_clear_library_path (druid->gen); /* Create list of projects */ druid->header_list = npw_header_list_new (); if (templates != NULL) { if (g_file_query_file_type (templates, 0, NULL) == G_FILE_TYPE_DIRECTORY) { /* Read project template only in specified directory, * other directories can still be used to get included * files */ gchar *directory = g_file_get_path (templates); npw_header_list_readdir (&druid->header_list, directory); anjuta_autogen_set_library_path (druid->gen, directory); g_free (directory); } else { /* templates is a file, so read only it as a project template */ gchar *filename = g_file_get_path (templates); npw_header_list_read (&druid->header_list, filename); g_free (filename); } } dir = g_build_filename (g_get_user_data_dir (), "anjuta", "templates", NULL); if (templates == NULL) { /* Read project template in user directory, * normally ~/.local/share/anjuta/templates, * the first template read override the others */ npw_header_list_readdir (&druid->header_list, dir); } anjuta_autogen_set_library_path (druid->gen, dir); g_free (dir); for (sys_dir = g_get_system_data_dirs (); *sys_dir != NULL; sys_dir++) { dir = g_build_filename (*sys_dir, "anjuta", "templates", NULL); if (templates == NULL) { /* Read project template in system directory */ npw_header_list_readdir (&druid->header_list, dir); } anjuta_autogen_set_library_path (druid->gen, dir); g_free (dir); } if (templates == NULL) { /* Read anjuta installation directory */ npw_header_list_readdir (&druid->header_list, PROJECT_WIZARD_DIRECTORY); } anjuta_autogen_set_library_path (druid->gen, PROJECT_WIZARD_DIRECTORY); switch (g_list_length (druid->header_list)) { case 0: anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (druid->plugin)->shell),_("Unable to find any project template in %s"), PROJECT_WIZARD_DIRECTORY); return FALSE; case 1: druid->header = (NPWHeader *)((GList *)druid->header_list->data)->data; druid->no_selection = TRUE; gtk_container_remove (GTK_CONTAINER (druid->window), druid->project_page); gtk_assistant_insert_page (GTK_ASSISTANT (druid->window), druid->progress_page, 0); npw_druid_set_busy (druid, FALSE); break; default: /* Add all necessary notebook page */ druid->no_selection = FALSE; g_list_foreach (druid->header_list, cb_druid_insert_project_page, druid); gtk_widget_show_all (GTK_WIDGET (druid->project_book)); } return TRUE; }