static gchar *untitled_title (tabwin_t *tabwin) { GtkNotebook *notebook = GTK_NOTEBOOK(tabwin->tabs); GtkWidget *page; windata_t *vwin; int i, np, idx = 0; np = gtk_notebook_get_n_pages(notebook); for (i=0; i<np; i++) { page = gtk_notebook_get_nth_page(notebook, i); vwin = g_object_get_data(G_OBJECT(page), "vwin"); if (strstr(vwin->fname, "script_tmp") != NULL) { idx++; } } if (idx > 0) { return g_strdup_printf("%s(%d)", _("untitled"), idx); } else { return g_strdup(_("untitled")); } }
static void page_added_callback (GtkNotebook *notebook, GtkWidget *child, gint pgnum, gpointer data) { int i, np = gtk_notebook_get_n_pages(notebook); GtkWidget *tab; if (np >= 5) { gtk_notebook_popup_enable(notebook); } if (np > 1) { for (i=0; i<np; i++) { tab = gtk_notebook_get_nth_page(notebook, i); gtk_notebook_set_tab_detachable(notebook, tab, TRUE); viewer_tab_show_closer(notebook, tab, TRUE); } } else { tab = gtk_notebook_get_nth_page(notebook, 0); viewer_tab_show_closer(notebook, tab, FALSE); } }
static void anjuta_docman_update_documents_menu_status (AnjutaDocman* docman) { AnjutaDocmanPriv *priv = docman->priv; GtkUIManager* ui = GTK_UI_MANAGER (anjuta_shell_get_ui (ANJUTA_PLUGIN (priv->plugin)->shell, NULL)); GtkAction* action; gint n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (docman)); gint current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (docman)); gchar *action_name; action = gtk_ui_manager_get_action (ui, "/MenuMain/PlaceHolderDocumentsMenus/Documents/PreviousDocument"); g_object_set (action, "sensitive", current_page > 0, NULL); action = gtk_ui_manager_get_action (ui, "/MenuMain/PlaceHolderDocumentsMenus/Documents/NextDocument"); g_object_set (action, "sensitive", (current_page + 1) < n_pages, NULL); action_name = g_strdup_printf ("Tab_%d", current_page); action = gtk_action_group_get_action (docman->priv->documents_action_group, action_name); g_free (action_name); if (action) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); }
void nautilus_notebook_next_page (NautilusNotebook *notebook) { gint current_page, n_pages; g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); if (current_page < n_pages - 1) gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); else { gboolean wrap_around; g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)), "gtk-keynav-wrap-around", &wrap_around, NULL); if (wrap_around) gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); } }
static gboolean auto_save(gpointer data) { GeanyDocument *doc; GeanyDocument *cur_doc = document_get_current(); gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(geany->main_widgets->notebook)); gint saved_files = 0; if (cur_doc == NULL) return TRUE; if (autosave_save_all) { for (i = 0; i < max; i++) { doc = document_get_from_page(i); /* skip current file (save it last), skip files without name */ if (doc != cur_doc && doc->file_name != NULL) if (document_save_file(doc, FALSE)) saved_files++; } } /* finally save current file, do it after all other files to get correct window title and * symbol list */ if (cur_doc->file_name != NULL) if (document_save_file(cur_doc, FALSE)) saved_files++; if (saved_files > 0 && autosave_print_msg) ui_set_statusbar(FALSE, ngettext( "Autosave: Saved %d file automatically.", "Autosave: Saved %d files automatically.", saved_files), saved_files); return TRUE; }
/************* * Callbacks * *************/ G_MODULE_EXPORT gboolean on_gui_key_press(GtkWidget *widget, GdkEventKey *event, AWeatherGui *self) { g_debug("AWeatherGui: on_gui_key_press - key=%x, state=%x", event->keyval, event->state); GObject *action = aweather_gui_get_object(self, "fullscreen"); gboolean full = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); if (event->keyval == GDK_KEY_q) gtk_widget_destroy(GTK_WIDGET(self)); else if (event->keyval == GDK_KEY_F11 || (event->keyval == GDK_KEY_Escape && full)) gtk_action_activate(GTK_ACTION(action)); else if (event->keyval == GDK_KEY_r && event->state & GDK_CONTROL_MASK) grits_viewer_refresh(self->viewer); else if (event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab) { GtkNotebook *tabs = GTK_NOTEBOOK(aweather_gui_get_widget(self, "main_tabs")); gint num_tabs = gtk_notebook_get_n_pages(tabs); gint cur_tab = gtk_notebook_get_current_page(tabs); if (event->state & GDK_SHIFT_MASK) gtk_notebook_set_current_page(tabs, (cur_tab-1)%num_tabs); else gtk_notebook_set_current_page(tabs, (cur_tab+1)%num_tabs); }; return FALSE; }
VISIBLE void removeAllBookmarks(GtkWidget *widget,GtkTextIter *titer) { ERRDATA pageStruct *page=NULL; int numpages; GtkTextIter startiter; GtkTextIter enditer; numpages=gtk_notebook_get_n_pages(mainNotebook); for(int j=0; j<numpages; j++) { page=getPageStructByIDFromPage(j); if(page!=NULL) { gtk_text_buffer_get_start_iter((GtkTextBuffer*)page->buffer,&startiter); gtk_text_buffer_get_end_iter((GtkTextBuffer*)page->buffer,&enditer); gtk_source_buffer_remove_source_marks(page->buffer,&startiter,&enditer,NULL); } } g_list_free_full(newBookMarksList,destroyBMData); newBookMarksList=NULL; rebuildBookMarkMenu(); gtk_widget_show_all(bookMarkMenu); }
static void debug_logger_clear_clicked(GtkWidget *widget, DebugLogger *logger) { GtkTreeView *view; GtkListStore *store; gint current_page; g_return_if_fail(IS_DEBUG_LOGGER(logger)); if(gtk_notebook_get_n_pages(logger->priv->notebook) == 0) return; current_page = gtk_notebook_get_current_page(logger->priv->notebook); view = GTK_TREE_VIEW(gtk_bin_get_child( GTK_BIN(gtk_notebook_get_nth_page( GTK_NOTEBOOK(logger->priv->notebook), current_page)))); store = GTK_LIST_STORE(gtk_tree_view_get_model(view)); gtk_list_store_clear(store); }
static void switch_page(PidginWindow *win, GtkDirectionType dir) { int count, current; #if GTK_CHECK_VERSION(2,2,0) count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook)); #else count = g_list_length(GTK_NOTEBOOK(win->notebook)->children); #endif current = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); if (dir == GTK_DIR_LEFT) { gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), current - 1); } else if (dir == GTK_DIR_RIGHT) { if (current == count - 1) gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); else gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), current + 1); } }
void show_tabbed_viewer (windata_t *vwin) { tabwin_t *tabwin = vwin_get_tabwin(vwin); GtkNotebook *notebook = GTK_NOTEBOOK(tabwin->tabs); int np = gtk_notebook_get_n_pages(notebook); gtk_widget_show_all(vwin->main); if (np > 1) { int pgnum = gtk_notebook_page_num(notebook, vwin->main); gtk_notebook_set_current_page(notebook, pgnum); } #if GTK_MAJOR_VERSION == 2 && GTK_MAJOR_VERSION < 18 if (!GTK_WIDGET_VISIBLE(tabwin->main)) { gtk_widget_show_all(tabwin->main); } #else if (!gtk_widget_get_visible(tabwin->main)) { gtk_widget_show_all(tabwin->main); } #endif if (vwin->role == EDIT_SCRIPT) { gtk_drag_dest_set(vwin->text, GTK_DEST_DEFAULT_ALL, tabwin_drag_targets, 1, GDK_ACTION_COPY); g_signal_connect(G_OBJECT(vwin->text), "drag-data-received", G_CALLBACK(tabwin_handle_drag), tabwin); } gtk_window_present(GTK_WINDOW(tabwin->main)); }
static void debug_logger_select_clicked(GtkWidget *widget, DebugLogger *logger) { GtkTreeView *view; GtkTreeSelection *selection; gint current_page; g_return_if_fail(IS_DEBUG_LOGGER(logger)); if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0) return; current_page = gtk_notebook_get_current_page(logger->priv->notebook); view = GTK_TREE_VIEW(gtk_bin_get_child( GTK_BIN(gtk_notebook_get_nth_page( GTK_NOTEBOOK(logger->priv->notebook), current_page)))); selection = gtk_tree_view_get_selection(view); gtk_tree_selection_select_all(selection); }
static void adapter_removed(GtkTreeModel *model, GtkTreePath *path, gpointer user_data) { GtkNotebook *notebook = user_data; int i, count = gtk_notebook_get_n_pages(notebook); for (i = 0; i < count; i++) { GtkWidget *widget; adapter_data *adapter; widget = gtk_notebook_get_nth_page(notebook, i); if (widget == NULL) continue; adapter = g_object_get_data(G_OBJECT(widget), "adapter"); if (adapter == NULL) continue; if (gtk_tree_row_reference_valid(adapter->reference) == TRUE) continue; gtk_tree_row_reference_free(adapter->reference); adapter->reference = NULL; gtk_notebook_remove_page(notebook, i); set_current_page (notebook); /* When the default adapter changes, the adapter_changed signal will * take care of setting the right page */ g_signal_handlers_disconnect_by_func(adapter->proxy, property_changed, adapter); g_object_unref(adapter->proxy); g_free(adapter); } }
gint tabmanagergui_get_n_pages (void) { return gtk_notebook_get_n_pages (g_tabnotebook); }
/** * Callback function of the conversation window's key-press event. */ static gboolean key_press_func(GtkWidget *widget, GdkEventKey *event, HybridConversation *conv) { gint current_page; gint pages; GSList *pos; HybridChatWindow *chat; if (event->state & GDK_CONTROL_MASK) { /* CTRL+W close the chat tab. */ if (event->keyval == GDK_w) { /* find the current chat panel. */ current_page = gtk_notebook_current_page( GTK_NOTEBOOK(conv->notebook)); for (pos = conv->chat_buddies; pos; pos = pos->next) { chat = (HybridChatWindow*)pos->data; if (current_page == gtk_notebook_page_num( GTK_NOTEBOOK(conv->notebook), chat->vbox)) { close_tab(chat); return TRUE; } } hybrid_debug_error("conv", "FATAL, can't find chat panel"); return FALSE; } /* CTRL+Q close the window. */ if (event->keyval == GDK_q) { gtk_widget_destroy(conv->window); return TRUE; } /* CTRL+TAB move to next page. */ if (event->keyval == GDK_Tab) { pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(conv->notebook)); if (pages == 1) { return TRUE; } else { current_page = gtk_notebook_current_page( GTK_NOTEBOOK(conv->notebook)); if (pages - 1 == current_page) { gtk_notebook_set_current_page(GTK_NOTEBOOK(conv->notebook), 0); } else { gtk_notebook_next_page(GTK_NOTEBOOK(conv->notebook)); } } return TRUE; } } return FALSE; }
void open_new_tab_cb (GtkMenuItem *button, MinimoBrowser *browser) { GtkWidget *page_label; gint num_pages; gchar *page_title; gint current_page; g_return_if_fail(browser->notebook != NULL); /* right button click emulation initialization */ rButtonClick = (RightButtonClick*) malloc(sizeof(RightButtonClick)); rButtonClick->sig_handler= 0; rButtonClick->is_connected= FALSE; num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)); page_title = g_strdup_printf("%d",num_pages+1); page_label = gtk_label_new (page_title); browser->mozEmbed = gtk_moz_embed_new(); gtk_notebook_append_page (GTK_NOTEBOOK (browser->notebook), browser->mozEmbed, page_label); gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (browser->notebook), browser->mozEmbed, FALSE, FALSE, GTK_PACK_START); gtk_widget_show (browser->mozEmbed); current_page = gtk_notebook_page_num (GTK_NOTEBOOK (browser->notebook), browser->mozEmbed); gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), current_page); browser->active_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), current_page); num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (browser->notebook)); browser->progressPopup = create_minimo_progress(browser); gtk_box_pack_start(GTK_BOX(browser->topLevelVBox), browser->progressPopup, FALSE, // expand FALSE, // fill 0); // padding /* applying the Signal into the new Render Engine - MozEmbed */ // hook up the title change to update the window title g_signal_connect (GTK_OBJECT (browser->mozEmbed), "title", G_CALLBACK (title_changed_cb), browser); g_signal_connect (GTK_OBJECT (browser->mozEmbed), "location", G_CALLBACK(location_changed_cb), page_label); // hook up the start and stop signals g_signal_connect (GTK_OBJECT (browser->mozEmbed), "net_start", G_CALLBACK(load_started_cb), browser); g_signal_connect (GTK_OBJECT (browser->mozEmbed), "net_stop", G_CALLBACK(load_finished_cb), browser); // hookup to see whenever a new window is requested //g_signal_connect (GTK_OBJECT (browser->mozEmbed), "new_window", G_CALLBACK(new_window_cb), browser); // hookup to any requested visibility changes g_signal_connect(GTK_OBJECT(browser->mozEmbed), "visibility", G_CALLBACK(visibility_cb), browser); // hookup to the signal that is called when someone clicks on a link to load a new uri g_signal_connect (GTK_OBJECT (browser->mozEmbed), "open_uri", G_CALLBACK(open_uri_cb), browser); // this signal is emitted when there's a request to change the containing browser window to a certain height, like with width // and height args for a window.open in javascript g_signal_connect (GTK_OBJECT (browser->mozEmbed), "size_to", G_CALLBACK(size_to_cb), browser); g_signal_connect (GTK_OBJECT (browser->mozEmbed), "link_message",G_CALLBACK (link_message_cb), browser); // this signals are emitted when the mouse is clicked, then we can measure the time between pressed and released for left click or right click g_signal_connect (GTK_OBJECT (browser->mozEmbed), "dom_mouse_down", G_CALLBACK(on_button_pressed_cb), browser); g_signal_connect (GTK_OBJECT (browser->mozEmbed), "dom_mouse_up", G_CALLBACK(on_button_released_cb), browser); gMinimoNumBrowsers= num_pages; }
void debug_logger_remove_domain(DebugLogger *logger, const gchar *domain_name) { GSList *entry; gint i, num_pages; g_return_if_fail(IS_DEBUG_LOGGER(logger)); if(!domain_name) return; for(entry = logger->priv->domains; entry != NULL; entry = g_slist_next(entry)) { DomainHandler *handler = entry->data; if(strcmp( domain_name, handler->name ) == 0) { g_log_remove_handler( (handler->default_domain) ? NULL : handler->name, handler->handler_id); if(logger->ui_enabled) { num_pages = gtk_notebook_get_n_pages(logger->priv->notebook); for(i = 0; i < num_pages; ++i) { GtkWidget *current_page = gtk_notebook_get_nth_page(logger->priv->notebook, i); GtkWidget *box = gtk_notebook_get_tab_label(logger->priv->notebook, current_page); GList *list = gtk_container_get_children(GTK_CONTAINER(box)); GtkLabel *label = GTK_LABEL(list->next->data); g_list_free(list); if( strcmp(domain_name, gtk_label_get_text(label)) == 0) { gtk_notebook_remove_page(logger->priv->notebook, i); break; } } } if(handler->name) g_free(handler->name); if(handler) g_free(handler); logger->priv->domains = g_slist_remove(logger->priv->domains, handler); } } if(logger->ui_enabled) { if(gtk_notebook_get_n_pages(logger->priv->notebook) == 0) { gtk_widget_set_sensitive(logger->priv->toolbar_save, FALSE); gtk_widget_set_sensitive(logger->priv->toolbar_copy, FALSE); gtk_widget_set_sensitive(logger->priv->toolbar_select, FALSE); gtk_widget_set_sensitive(logger->priv->toolbar_clear, FALSE); } } }
static VALUE rg_n_pages(VALUE self) { return INT2NUM(gtk_notebook_get_n_pages(_SELF(self))); }
/** \brief Create and initialise module manger. * \return The main module container widget (GtkNotebook). * * This function creates and initialises the module manager widget, which * consist of a GtkNotebook container. Before returning the container to the * caller, the function checks whether any modules should be restored (ie. * openend), if yes, it creates them and adds them to the notebook. * */ GtkWidget * mod_mgr_create (void) { gchar *openmods = NULL; gchar **mods; gint count,i; GtkWidget *module; gchar *modfile; gchar *confdir; /* create notebook */ nbook = gtk_notebook_new (); gtk_notebook_set_scrollable (GTK_NOTEBOOK (nbook), TRUE); gtk_notebook_popup_enable (GTK_NOTEBOOK (nbook)); g_object_set (G_OBJECT (nbook), "homogeneous", TRUE, NULL); g_signal_connect (G_OBJECT (nbook), "switch-page", G_CALLBACK (switch_page_cb), NULL); /* get list of modules which should be open */ openmods = sat_cfg_get_str (SAT_CFG_STR_OPEN_MODULES); if (openmods) { mods = g_strsplit (openmods, ";", 0); count = g_strv_length (mods); for (i = 0; i < count; i++) { /* get data file name */ confdir = get_modules_dir (); modfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, mods[i], ".mod", NULL); g_free (confdir); /* create module */ module = gtk_sat_module_new (modfile); if (IS_GTK_SAT_MODULE (module)) { /* if module state was window or user does not want to restore the state of the modules, pack the module into the notebook */ if ((GTK_SAT_MODULE (module)->state == GTK_SAT_MOD_STATE_DOCKED) || !sat_cfg_get_bool (SAT_CFG_BOOL_MOD_STATE)) { mod_mgr_add_module (module, TRUE); } else { mod_mgr_add_module (module, FALSE); create_module_window (module); } } else { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to restore %s"), __FUNCTION__, mods[i]); } g_free (modfile); } g_strfreev (mods); g_free (openmods); /* disable tabs if only one page in notebook */ if ((gtk_notebook_get_n_pages (GTK_NOTEBOOK(nbook))) == 1) { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), FALSE); } else { gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nbook), TRUE); } } else { sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: No modules have to be restored."), __FUNCTION__); } return nbook; }
void termit_prev_tab() { gint index = gtk_notebook_get_current_page(GTK_NOTEBOOK(termit.notebook)); index = (index) ? index - 1 : gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) - 1; termit_activate_tab(index); }
void termit_close_tab() { termit_del_tab(); if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(termit.notebook)) == 0) termit_quit(); }
static void debug_logger_save_clicked(GtkWidget *widget, DebugLogger *logger) { GladeXML *glade; GtkWidget *dialog; gint result; GList *selected_rows = NULL, *entry; GtkTreeView *view; GtkTreeModel *model; GtkTreeSelection *selection; gint current_page; GString *copy_data; g_return_if_fail(IS_DEBUG_LOGGER(logger)); if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0) return; glade = glade_xml_new(GLADEDIR "/main.glade", "save_dialog", NULL); dialog = glade_xml_get_widget(glade, "save_dialog"); copy_data = g_string_new(NULL); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "debug.log"); result = gtk_dialog_run(GTK_DIALOG(dialog)); if(result == GTK_RESPONSE_OK) { gchar *filename; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); current_page = gtk_notebook_get_current_page(logger->priv->notebook); view = GTK_TREE_VIEW(gtk_bin_get_child( GTK_BIN(gtk_notebook_get_nth_page( GTK_NOTEBOOK(logger->priv->notebook), current_page)))); model = gtk_tree_view_get_model(view); selection = gtk_tree_view_get_selection(view); gtk_tree_selection_select_all(selection); selected_rows = gtk_tree_selection_get_selected_rows(selection, &model); for(entry = selected_rows; entry != NULL; entry = g_list_next(entry)) { GtkTreeIter iter; gchar *message; gtk_tree_model_get_iter(model, &iter, entry->data); gtk_tree_model_get(model, &iter, MSG_COLUMN, &message, -1); copy_data = g_string_append(copy_data, message); copy_data = g_string_append_c(copy_data, '\n'); g_free(message); } gtk_tree_selection_unselect_all(selection); g_file_set_contents(filename, copy_data->str, copy_data->len, NULL); g_free(filename); } g_string_free(copy_data, TRUE); g_list_foreach(selected_rows, (GFunc)gtk_tree_path_free, NULL); g_list_free(selected_rows); gtk_widget_destroy(dialog); g_object_unref(glade); }
void debug_searching_and_replace_by_signal_emit(GtkWidget *widget, gpointer user_data) { /** To perform this test you must open any files, * and press the "Replace debug" button. ********************************************************************************/ int c ; GtkWidget *widgets[5]={gui->search_and_replace->search_button, gui->search_and_replace->replace_one_button, gui->search_and_replace->search_next_button, gui->search_and_replace->replace_all_button, gui->search_and_replace->search_prev_button } ; GtkWidget *widget_emitter = NULL ; GRand *rand ; struct timeval tv ; gettimeofday(&tv, NULL) ; for (c=0 ; c < 1024 ; c++) { g_usleep(tv.tv_usec % 256) ; gettimeofday(&tv, NULL) ; rand = g_rand_new_with_seed((guint32) tv.tv_usec); if ( g_rand_int(rand) % 5 == 0 ) { widget_emitter = widgets[g_rand_int(rand) % 5] ; } g_usleep(tv.tv_usec % 256) ; gettimeofday(&tv, NULL) ; rand = g_rand_new_with_seed((guint32) tv.tv_usec); if (g_rand_int(rand) % 5 == 0) { gtk_entry_set_text(GTK_ENTRY(gui->search_and_replace->search_entry), "") ; } else { char char_one = get_rand_ascii_print() ; char char_two = get_rand_ascii_print() ; char text[3]={char_one,char_two,'\0'} ; gtk_entry_set_text(GTK_ENTRY(gui->search_and_replace->search_entry), text) ; } g_usleep(tv.tv_usec % 256) ; gettimeofday(&tv, NULL) ; rand = g_rand_new_with_seed((guint32) tv.tv_usec); if (g_rand_int(rand) % 5 == 0) { gtk_entry_set_text(GTK_ENTRY(gui->search_and_replace->replace_entry), "") ; } else { char char_one = get_rand_ascii_print() ; char char_two = get_rand_ascii_print() ; char text[3]={char_one,char_two,'\0'} ; gtk_entry_set_text(GTK_ENTRY(gui->search_and_replace->replace_entry), text) ; } g_usleep(tv.tv_usec % 256) ; gettimeofday(&tv, NULL) ; rand = g_rand_new_with_seed((guint32) tv.tv_usec); if (g_rand_int(rand) % 5 == 0) { gtk_notebook_set_current_page(GTK_NOTEBOOK(gui->editor_notebook), g_rand_int(rand) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(gui->editor_notebook)) ) ; } g_signal_emit_by_name((gpointer) widget_emitter, "clicked", NULL); while (gtk_events_pending()) { gtk_main_iteration() ; } g_usleep(125000/5) ; } fprintf(stdout,"End of tests successfull !!!\n") ; fflush(stdout) ; return ; }
g_signal_connect (app, "add-browser", G_CALLBACK (tab_panel_app_add_browser_cb), extension); } static void tab_panel_browser_move_tab_cb (MidoriBrowser* browser, GtkNotebook* notebook, gint cur_pos, gint new_pos, gpointer user_data) { GtkTreeIter cur, new; gint last_page; GtkTreeModel *model; last_page = gtk_notebook_get_n_pages (notebook) - 1; model = tab_panel_get_model_for_browser (browser); gtk_tree_model_iter_nth_child (model, &cur, NULL, cur_pos); if (cur_pos == 0 && new_pos == last_page) gtk_tree_store_move_before (GTK_TREE_STORE (model), &cur, NULL); else if (cur_pos == last_page && new_pos == 0) gtk_tree_store_move_after (GTK_TREE_STORE (model), &cur, NULL); else { gtk_tree_model_iter_nth_child (model, &new, NULL, new_pos); gtk_tree_store_swap (GTK_TREE_STORE (model), &cur, &new); } }
void clearlooks_get_notebook_tab_position (GtkWidget *widget, gboolean *start, gboolean *end) { /* default value */ *start = TRUE; *end = FALSE; if (GE_IS_NOTEBOOK (widget)) { gboolean found_tabs = FALSE; gint i, n_pages; GtkNotebook *notebook = GTK_NOTEBOOK (widget); /* got a notebook, so walk over all the tabs and decide based * on that ... * It works like this: * - If there is any visible tab that is expanded, set both. * - Set start/end if there is any visible tab that is at * the start/end. * - If one has the child_visibility set to false, arrows * are present; so none * The heuristic falls over if there is a notebook that just * happens to fill up all the available space. ie. All tabs * are left aligned, but it does not require scrolling. * (a more complex heuristic could calculate the tabs width * and add them all up) */ n_pages = gtk_notebook_get_n_pages (notebook); for (i = 0; i < n_pages; i++) { GtkWidget *tab_child; GtkWidget *tab_label; gboolean expand; GtkPackType pack_type; tab_child = gtk_notebook_get_nth_page (notebook, i); /* Skip invisible tabs */ tab_label = gtk_notebook_get_tab_label (notebook, tab_child); if (!tab_label || !GTK_WIDGET_VISIBLE (tab_label)) continue; /* This is the same what the notebook does internally. */ if (tab_label && !gtk_widget_get_child_visible (tab_label)) { /* One child is hidden because scroll arrows are present. * So both corners are rounded. */ *start = FALSE; *end = FALSE; return; } gtk_notebook_query_tab_label_packing (notebook, tab_child, &expand, NULL, /* don't need fill */ &pack_type); if (!found_tabs) { found_tabs = TRUE; *start = FALSE; *end = FALSE; } if (expand) { *start = TRUE; *end = TRUE; } else if (pack_type == GTK_PACK_START) { *start = TRUE; } else { *end = TRUE; } } } }
static void gail_notebook_real_notify_gtk (GObject *obj, GParamSpec *pspec) { GtkWidget *widget; AtkObject* atk_obj; widget = GTK_WIDGET (obj); atk_obj = gtk_widget_get_accessible (widget); if (strcmp (pspec->name, "page") == 0) { gint page_num, old_page_num; gint focus_page_num = 0; gint old_focus_page_num; GailNotebook *gail_notebook; GtkNotebook *gtk_notebook; gail_notebook = GAIL_NOTEBOOK (atk_obj); gtk_notebook = GTK_NOTEBOOK (widget); if (gail_notebook->page_count < gtk_notebook_get_n_pages (gtk_notebook)) check_cache (gail_notebook, gtk_notebook); /* * Notify SELECTED state change for old and new page */ old_page_num = gail_notebook->selected_page; page_num = gtk_notebook_get_current_page (gtk_notebook); gail_notebook->selected_page = page_num; gail_notebook->focus_tab_page = page_num; old_focus_page_num = gail_notebook->focus_tab_page; if (page_num != old_page_num) { AtkObject *obj; if (old_page_num != -1) { obj = gail_notebook_ref_child (atk_obj, old_page_num); if (obj) { atk_object_notify_state_change (obj, ATK_STATE_SELECTED, FALSE); g_object_unref (obj); } } obj = gail_notebook_ref_child (atk_obj, page_num); if (obj) { atk_object_notify_state_change (obj, ATK_STATE_SELECTED, TRUE); g_object_unref (obj); /* * The page which is being displayed has changed but there is * no need to tell the focus tracker as the focus page will also * change or a widget in the page will receive focus if the * Notebook does not have tabs. */ } g_signal_emit_by_name (atk_obj, "selection_changed"); g_signal_emit_by_name (atk_obj, "visible_data_changed"); } if (gtk_notebook_get_show_tabs (gtk_notebook) && (focus_page_num != old_focus_page_num)) { if (gail_notebook->idle_focus_id) g_source_remove (gail_notebook->idle_focus_id); gail_notebook->idle_focus_id = gdk_threads_add_idle (gail_notebook_check_focus_tab, atk_obj); } } else GAIL_WIDGET_CLASS (gail_notebook_parent_class)->notify_gtk (obj, pspec); }
gint main_window_key_press_event(GtkWidget *widget, GdkEventKey *event,gpointer user_data) { if (main_window.notebook_editor != NULL) { check_externally_modified(document_manager_get_current_document(main_window.docmg)); if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))==(GDK_CONTROL_MASK | GDK_SHIFT_MASK)) && (event->keyval == GDK_ISO_Left_Tab)) { // Hack, for some reason when shift is held down keyval comes through as GDK_ISO_Left_Tab not GDK_Tab if (gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window.notebook_editor)) == 0) { gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor), gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_window.notebook_editor))-1); } else { gtk_notebook_prev_page(GTK_NOTEBOOK(main_window.notebook_editor)); } return TRUE; } else if ((event->state & GDK_CONTROL_MASK)==GDK_CONTROL_MASK && (event->keyval == GDK_Tab)) { if (gtk_notebook_get_current_page(GTK_NOTEBOOK(main_window.notebook_editor)) == gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_window.notebook_editor))-1) { gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor),0); } else { gtk_notebook_next_page(GTK_NOTEBOOK(main_window.notebook_editor)); } return TRUE; } else if ((event->state & GDK_MOD1_MASK)==GDK_MOD1_MASK && ((event->keyval >= GDK_0) && (event->keyval <= GDK_9))) { gtk_notebook_set_current_page(GTK_NOTEBOOK(main_window.notebook_editor),event->keyval - ((event->keyval == GDK_0) ? (GDK_0 - 9) : (GDK_0 + 1))); return TRUE; } } return FALSE; }
/** * Run the Grisbi assistant. This will pop up a new dialog. * * \param assistant Grisbi assistant to run. * * \return Outcome of the Grisbi assistant. Can be * GTK_RESPONSE_APPLY for success and * GTK_RESPONSE_CANCEL for failure * (user canceled or closed dialog). */ GtkResponseType gsb_assistant_run ( GtkWidget * assistant ) { GtkWidget * notebook, * button_prev; GtkWidget *button_select; button_prev = g_object_get_data ( G_OBJECT(assistant), "button_prev" ); button_select = g_object_get_data ( G_OBJECT ( assistant ), "button_select" ); gtk_widget_show_all ( assistant ); gtk_widget_hide ( button_select ); notebook = g_object_get_data ( G_OBJECT(assistant), "notebook" ); gtk_notebook_set_current_page ( GTK_NOTEBOOK (notebook), 0 ); gtk_widget_grab_focus (GTK_WIDGET (g_object_get_data (G_OBJECT (assistant), "button_next"))); while ( TRUE ) { gint current = gtk_notebook_get_current_page ( GTK_NOTEBOOK(notebook) ); gint result, prev, next; gchar* tmpstr = g_strdup_printf ( _("%s (%d of %d)"), (gchar *) g_object_get_data ( G_OBJECT(assistant), "title" ), current + 1, gtk_notebook_get_n_pages ( GTK_NOTEBOOK(notebook) ) ); gtk_window_set_title ( GTK_WINDOW(assistant), tmpstr); g_free ( tmpstr ); result = gtk_dialog_run ( GTK_DIALOG(assistant) ); tmpstr = g_strdup_printf ( "prev%d", current ); prev = GPOINTER_TO_INT( g_object_get_data ( G_OBJECT(assistant), tmpstr )); g_free ( tmpstr ); tmpstr = g_strdup_printf ( "next%d", current ); next = GPOINTER_TO_INT( g_object_get_data ( G_OBJECT(assistant), tmpstr)); g_free ( tmpstr ); switch ( result ) { case GTK_RESPONSE_YES: gtk_widget_set_sensitive ( button_prev, TRUE ); if ( gtk_notebook_get_n_pages ( GTK_NOTEBOOK(notebook) ) == ( next + 1 ) ) { gsb_assistant_change_button_next ( assistant, GTK_STOCK_CLOSE, GTK_RESPONSE_APPLY ); gsb_assistant_sensitive_button_prev ( assistant, FALSE ); } gtk_notebook_set_current_page ( GTK_NOTEBOOK(notebook), next ); break; case GTK_RESPONSE_NO: if ( next == -1 ) { gsb_assistant_change_button_next ( assistant, GTK_STOCK_GO_FORWARD, GTK_RESPONSE_YES ); } gsb_assistant_sensitive_button_next ( assistant, TRUE ); if ( prev == 0 ) { gtk_widget_set_sensitive ( button_prev, FALSE ); } gtk_notebook_set_current_page ( GTK_NOTEBOOK(notebook), prev ); break; case GTK_RESPONSE_APPLY: return GTK_RESPONSE_APPLY; default: case GTK_RESPONSE_CANCEL: return GTK_RESPONSE_CANCEL; } } return GTK_RESPONSE_CANCEL; }
/** * Print the current page and page count of a notebook. * @param notebook notebook to print information about */ void mk_print_GtkNotebook_info(GtkNotebook* notebook) { gint current_page = gtk_notebook_get_current_page(notebook); gint n_pages = gtk_notebook_get_n_pages(notebook); g_printf("\t%d/%d", current_page, n_pages); }
static gint find_tab_num_at_pos (NautilusNotebook *notebook, gint abs_x, gint abs_y) { GtkPositionType tab_pos; int page_num = 0; GtkNotebook *nb = GTK_NOTEBOOK (notebook); GtkWidget *page; GtkAllocation allocation; tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook)); if (gtk_notebook_get_n_pages (nb) == 0) { return AFTER_ALL_TABS; } /* For some reason unfullscreen + quick click can cause a wrong click event to be reported to the tab */ if (!is_in_notebook_window(notebook, abs_x, abs_y)) { return NOT_IN_APP_WINDOWS; } while ((page = gtk_notebook_get_nth_page (nb, page_num))) { GtkWidget *tab; gint max_x, max_y; gint x_root, y_root; tab = gtk_notebook_get_tab_label (nb, page); g_return_val_if_fail (tab != NULL, -1); if (!gtk_widget_get_mapped (GTK_WIDGET (tab))) { page_num++; continue; } gdk_window_get_origin (gtk_widget_get_window (tab), &x_root, &y_root); gtk_widget_get_allocation (tab, &allocation); max_x = x_root + allocation.x + allocation.width; max_y = y_root + allocation.y + allocation.height; if (((tab_pos == GTK_POS_TOP) || (tab_pos == GTK_POS_BOTTOM)) &&(abs_x<=max_x)) { return page_num; } else if (((tab_pos == GTK_POS_LEFT) || (tab_pos == GTK_POS_RIGHT)) && (abs_y<=max_y)) { return page_num; } page_num++; } return AFTER_ALL_TABS; }
windata_t *tabwin_get_editor_for_file (const char *filename, GtkWidget *w) { windata_t *ret = NULL; if (w == tabedit->main) { GtkNotebook *notebook = GTK_NOTEBOOK(tabedit->tabs); int i, n = gtk_notebook_get_n_pages(notebook); GtkWidget *tab; windata_t *vwin; for (i=0; i<n; i++) { tab = gtk_notebook_get_nth_page(notebook, i); vwin = g_object_get_data(G_OBJECT(tab), "vwin"); if (vwin != NULL && !strcmp(filename, vwin->fname)) { ret = vwin; break; } } } return ret; }