int main( int argc, char *argv[] ) { GtkWidget *window = NULL; GtkWidget *box1; GtkWidget *box2; GtkWidget *button; GtkWidget *separator; GSList *group; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "delete-event", G_CALLBACK (close_application), NULL); gtk_window_set_title (GTK_WINDOW (window), "radio buttons"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); button = gtk_radio_button_new_with_label (NULL, "button1"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); button = gtk_radio_button_new_with_label (group, "button2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); gtk_widget_show (separator); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); gtk_widget_show (box2); button = gtk_button_new_with_label ("close"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (close_application), window); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_set_can_default (button, TRUE); gtk_widget_grab_default (button); gtk_widget_show (button); gtk_widget_show (window); gtk_main (); return 0; }
static void create_lissajous (void) { GtkWidget *window = NULL; GtkWidget *box1; GtkWidget *box2; GtkWidget *close_button; GtkWidget *box; GtkWidget *label; GtkWidget *table; GtkWidget *separator; GtkDataboxGraph *graph; GdkRGBA color; gint i; lissajous_frequency = 0; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, 500, 500); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_window_set_title (GTK_WINDOW (window), "GtkDatabox: Lissajous Example"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box1); label = gtk_label_new ("This example resembles an oszilloscope\nreceiving two signals, one is a sine (horizontal),\nthe other is a cosine with ever changing frequency (vertical).\nThe counter is synchron with the updates."); gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0); separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0); lissajous_label = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (lissajous_label), "0"); gtk_box_pack_start (GTK_BOX (box1), lissajous_label, FALSE, FALSE, 0); separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0); lissajous_idle = 0; lissajous_frequency = 3. * G_PI / 2.; lissajous_counter = 0; /* Create a GtkDatabox widget along with scrollbars and rulers */ gtk_databox_create_box_with_scrollbars_and_rulers (&box, &table, TRUE, TRUE, TRUE, TRUE); g_object_set(G_OBJECT(box), "expand", TRUE, NULL); gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0); color.red = 0; color.green = 0; color.blue = 0.5; color.alpha = 1; gtk_widget_override_background_color (box, GTK_STATE_FLAG_NORMAL, &color); lissajousX = g_new0 (gfloat, POINTS); lissajousY = g_new0 (gfloat, POINTS); for (i = 0; i < POINTS; i++) { lissajousX[i] = 100. * sin (i * 4 * G_PI / POINTS); lissajousY[i] = 100. * cos (i * 4 * G_PI / POINTS); } color.red = 1; color.green = 1; color.blue = 0; color.alpha = 1; graph = gtk_databox_lines_new (POINTS, lissajousX, lissajousY, &color, 1); gtk_databox_graph_add (GTK_DATABOX (box), graph); gtk_databox_auto_rescale (GTK_DATABOX (box), 0.05); separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_end (GTK_BOX (box1), box2, FALSE, TRUE, 0); close_button = gtk_button_new_with_label ("close"); g_signal_connect_swapped (G_OBJECT (close_button), "clicked", G_CALLBACK (gtk_main_quit), G_OBJECT (box)); gtk_box_pack_start (GTK_BOX (box2), close_button, TRUE, TRUE, 0); gtk_widget_set_can_default(close_button, TRUE); gtk_widget_grab_default (close_button); lissajous_idle = g_idle_add ((GSourceFunc) lissajous_idle_func, box); gtk_widget_show_all (window); }
static void gtk_get_credentials(struct cli_credentials *credentials) { const char *ret; GtkWidget *dialog; GtkWidget *label; GtkWidget *table; GtkWidget *entry_username; GtkWidget *dialog_action_area1; GtkWidget *cancelbutton1; GtkWidget *okbutton1; #ifndef HAVE_GNOME_KEYRING GtkWidget *anonymous; #endif const char *username; dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), "Credentials"); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG); table = gtk_table_new(4, 2, FALSE); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), table); label = gtk_label_new ("Username:"******"Password:"******"_Anonymous"); gtk_table_attach(GTK_TABLE(table),anonymous,0,2,4,5,GTK_FILL,0,0,0); #endif dialog_action_area1 = GTK_DIALOG (dialog)->action_area; gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancelbutton1, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default(cancelbutton1, TRUE); okbutton1 = gtk_button_new_from_stock ("gtk-ok"); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), okbutton1, GTK_RESPONSE_OK); gtk_widget_set_can_default(okbutton1, TRUE); gtk_widget_show_all (dialog); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_OK: cli_credentials_parse_string(credentials, gtk_entry_get_text(GTK_ENTRY(entry_username)), CRED_CALLBACK_RESULT); #ifndef HAVE_GNOME_KEYRING cli_credentials_set_password(credentials, gtk_entry_get_text(GTK_ENTRY(entry_password)), CRED_CALLBACK_RESULT); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(anonymous))) { cli_credentials_set_anonymous(credentials); } #endif break; default: ret = NULL; break; } gtk_widget_destroy (dialog); }
GtkDialog* seahorse_passphrase_prompt_show (const gchar *title, const gchar *description, const gchar *prompt, const gchar *check, gboolean confirm) { GtkEntryBuffer *buffer; GtkEntry *entry; GtkDialog *dialog; GtkWidget *w; GtkWidget *box; GtkTable *table; GtkWidget *wvbox; GtkWidget *chbox; gchar *msg; if (!title) title = _("Passphrase"); if (!prompt) prompt = _("Password:"******"size-request", G_CALLBACK (constrain_size), NULL); g_signal_connect (G_OBJECT (dialog), "map-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "unmap-event", G_CALLBACK (ungrab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "window-state-event", G_CALLBACK (window_state_changed), NULL); wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), wvbox); gtk_container_set_border_width (GTK_CONTAINER (wvbox), HIG_LARGE); chbox = gtk_hbox_new (FALSE, HIG_LARGE); gtk_box_pack_start (GTK_BOX (wvbox), chbox, FALSE, FALSE, 0); /* The image */ w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (chbox), w, FALSE, FALSE, 0); box = gtk_vbox_new (FALSE, HIG_SMALL); gtk_box_pack_start (GTK_BOX (chbox), box, TRUE, TRUE, 0); /* The description text */ if (description) { msg = utf8_validate (description); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0); } /* Two entries (usually on is hidden) in a vbox */ table = GTK_TABLE (gtk_table_new (3, 2, FALSE)); gtk_table_set_row_spacings (table, HIG_SMALL); gtk_table_set_col_spacings (table, HIG_LARGE); gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (table), FALSE, FALSE, 0); /* The first entry if we have one */ if (confirm) { msg = utf8_validate (prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_entry_set_visibility (entry, FALSE); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); g_object_set_data (G_OBJECT (dialog), "confirm-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (confirm_callback), dialog); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 0, 1); gtk_widget_grab_focus (GTK_WIDGET (entry)); } /* The second and main entry */ msg = utf8_validate (confirm ? _("Confirm:") : prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); gtk_entry_set_visibility (entry, FALSE); g_object_set_data (G_OBJECT (dialog), "secure-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 1, 2); if (!confirm) gtk_widget_grab_focus (GTK_WIDGET (entry)); else g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); /* The checkbox */ if (check) { w = gtk_check_button_new_with_mnemonic (check); gtk_table_attach_defaults (table, w, 1, 2, 2, 3); g_object_set_data (G_OBJECT (dialog), "check-option", w); } gtk_widget_show_all (GTK_WIDGET (table)); w = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_REJECT); gtk_widget_set_can_default (w, TRUE); w = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_ACCEPT); gtk_widget_set_can_default (w, TRUE); g_signal_connect_object (G_OBJECT (entry), "focus_in_event", G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0); gtk_widget_grab_default (w); g_signal_connect (dialog, "key_press_event", G_CALLBACK (key_press), NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); gtk_widget_show_all (GTK_WIDGET (dialog)); gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (dialog)), GDK_CURRENT_TIME); if (confirm) entry_changed (NULL, dialog); return dialog; }
static void gdict_applet_build_window (GdictApplet *applet) { GdictAppletPrivate *priv = applet->priv; GtkWidget *window; GtkWidget *frame; GtkWidget *vbox; GtkWidget *bbox; GtkWidget *button; if (!priv->entry) { g_warning ("No entry widget defined"); return; } window = gdict_aligned_window_new (priv->toggle); g_signal_connect (window, "key-press-event", G_CALLBACK (window_key_press_event_cb), applet); g_signal_connect (window, "show", G_CALLBACK (window_show_cb), applet); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (window), frame); gtk_widget_show (frame); priv->frame = frame; vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); priv->defbox = gdict_defbox_new (); if (priv->context) gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), priv->context); gtk_box_pack_start (GTK_BOX (vbox), priv->defbox, TRUE, TRUE, 0); gtk_widget_show (priv->defbox); gtk_widget_set_can_focus (priv->defbox, TRUE); gtk_widget_set_can_default (priv->defbox, TRUE); bbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing (GTK_BOX (bbox), 6); gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_widget_show (bbox); button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); gtk_widget_set_tooltip_text (button, _("Clear the definitions found")); set_atk_name_description (button, _("Clear definition"), _("Clear the text of the definition")); g_signal_connect (button, "clicked", G_CALLBACK (clear_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_PRINT); gtk_widget_set_tooltip_text (button, _("Print the definitions found")); set_atk_name_description (button, _("Print definition"), _("Print the text of the definition")); g_signal_connect (button, "clicked", G_CALLBACK (print_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_SAVE); gtk_widget_set_tooltip_text (button, _("Save the definitions found")); set_atk_name_description (button, _("Save definition"), _("Save the text of the definition to a file")); g_signal_connect (button, "clicked", G_CALLBACK (save_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gtk_window_set_default (GTK_WINDOW (window), priv->defbox); priv->window = window; priv->is_window_showing = FALSE; }
/** * thunar_dialogs_show_job_ask: * @parent : the parent #GtkWindow or %NULL. * @question : the question text. * @choices : possible responses. * * Utility function to display a question dialog for the ThunarJob::ask * signal. * * Return value: the #ThunarJobResponse. **/ ThunarJobResponse thunar_dialogs_show_job_ask (GtkWindow *parent, const gchar *question, ThunarJobResponse choices) { const gchar *separator; const gchar *mnemonic; GtkWidget *message; GtkWidget *button; GString *secondary = g_string_sized_new (256); GString *primary = g_string_sized_new (256); gint response; gint n; gboolean has_cancel = FALSE; _thunar_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), THUNAR_JOB_RESPONSE_CANCEL); _thunar_return_val_if_fail (g_utf8_validate (question, -1, NULL), THUNAR_JOB_RESPONSE_CANCEL); /* try to separate the question into primary and secondary parts */ separator = strstr (question, ": "); if (G_LIKELY (separator != NULL)) { /* primary is everything before the colon, plus a dot */ g_string_append_len (primary, question, separator - question); g_string_append_c (primary, '.'); /* secondary is everything after the colon (skipping whitespace) */ do ++separator; while (g_ascii_isspace (*separator)); g_string_append (secondary, separator); } else { /* otherwise separate based on the \n\n */ separator = strstr (question, "\n\n"); if (G_LIKELY (separator != NULL)) { /* primary is everything before the newlines */ g_string_append_len (primary, question, separator - question); /* secondary is everything after the newlines (skipping whitespace) */ while (g_ascii_isspace (*separator)) ++separator; g_string_append (secondary, separator); } else { /* everything is primary */ g_string_append (primary, question); } } /* allocate the question message dialog */ message = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary->str); if (G_LIKELY (*secondary->str != '\0')) gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s", secondary->str); /* add the buttons based on the possible choices */ for (n = 6; n >= 0; --n) { /* check if the response is set */ response = choices & (1 << n); if (response == 0) continue; switch (response) { case THUNAR_JOB_RESPONSE_YES: mnemonic = _("_Yes"); break; case THUNAR_JOB_RESPONSE_YES_ALL: mnemonic = _("Yes to _all"); break; case THUNAR_JOB_RESPONSE_NO: mnemonic = _("_No"); break; case THUNAR_JOB_RESPONSE_NO_ALL: mnemonic = _("N_o to all"); break; case THUNAR_JOB_RESPONSE_RETRY: mnemonic = _("_Retry"); break; case THUNAR_JOB_RESPONSE_FORCE: mnemonic = _("Copy _Anyway"); break; case THUNAR_JOB_RESPONSE_CANCEL: /* cancel is always the last option */ has_cancel = TRUE; continue; default: g_assert_not_reached (); break; } button = gtk_button_new_with_mnemonic (mnemonic); gtk_widget_set_can_default (button, TRUE); gtk_dialog_add_action_widget (GTK_DIALOG (message), button, response); gtk_widget_show (button); gtk_dialog_set_default_response (GTK_DIALOG (message), response); } if (has_cancel) { button = gtk_button_new_with_mnemonic (_("_Cancel")); gtk_widget_set_can_default (button, TRUE); gtk_dialog_add_action_widget (GTK_DIALOG (message), button, GTK_RESPONSE_CANCEL); gtk_widget_show (button); gtk_dialog_set_default_response (GTK_DIALOG (message), GTK_RESPONSE_CANCEL); } /* run the question dialog */ response = gtk_dialog_run (GTK_DIALOG (message)); gtk_widget_destroy (message); /* transform the result as required */ if (G_UNLIKELY (response <= 0)) response = THUNAR_JOB_RESPONSE_CANCEL; /* cleanup */ g_string_free (secondary, TRUE); g_string_free (primary, TRUE); return response; }
GtkWidget *gui_create_sidebar(GtkWidget *paned) { GtkWidget *vbox1; GtkWidget *scrolledwindow4; GtkWidget *scrolledwindow_bm; GtkWidget *title_label = NULL; #ifndef USE_WEBKIT2 GtkWidget *scrolledwindow; #endif GtkWidget *table2; UI_VBOX(vbox1, FALSE, 0); gtk_widget_show(vbox1); widgets.paned_sidebar = UI_VPANE(); gtk_paned_pack1(GTK_PANED(paned), widgets.paned_sidebar, FALSE, TRUE); gtk_widget_show(widgets.paned_sidebar); gtk_paned_pack1(GTK_PANED(widgets.paned_sidebar), vbox1, FALSE, TRUE); UI_VBOX(widgets.box_side_preview, FALSE, 0); gtk_paned_pack2(GTK_PANED(widgets.paned_sidebar), widgets.box_side_preview, FALSE, TRUE); gtk_container_set_border_width(GTK_CONTAINER(widgets.box_side_preview), 2); g_signal_connect(G_OBJECT(widgets.paned_sidebar), "button_release_event", G_CALLBACK(paned_button_release_event), (gchar *)"paned_sidebar"); widgets.shortcutbar = widgets.paned_sidebar; #ifndef USE_WEBKIT2 scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow); gtk_box_pack_start(GTK_BOX(widgets.box_side_preview), scrolledwindow, TRUE, TRUE, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *) scrolledwindow, settings.shadow_type); #endif sidebar.html_viewer_widget = GTK_WIDGET(XIPHOS_HTML_NEW(NULL, FALSE, SB_VIEWER_TYPE)); gtk_widget_show(sidebar.html_viewer_widget); #ifdef USE_WEBKIT2 gtk_box_pack_start(GTK_BOX(widgets.box_side_preview), sidebar.html_viewer_widget, TRUE, TRUE, 0); #else gtk_container_add(GTK_CONTAINER(scrolledwindow), sidebar.html_viewer_widget); #endif /* ---------------------------------------------------------------- */ /* 2x2 button box set: modules/bookmarks/search/vlist */ /* ---------------------------------------------------------------- */ #ifdef HAVE_GTK_34 table2 = gtk_grid_new(); gtk_widget_show(table2); gtk_box_pack_start(GTK_BOX(vbox1), table2, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(table2), 2); gtk_grid_set_row_spacing(GTK_GRID(table2), 6); gtk_grid_set_column_spacing(GTK_GRID(table2), 6); gtk_grid_set_row_homogeneous(GTK_GRID(table2), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID(table2), TRUE); button_bookmarks = gtk_toggle_button_new_with_mnemonic(_("Bookmarks")); gtk_widget_show(button_bookmarks); gtk_grid_attach(GTK_GRID(table2), button_bookmarks, 1, 0, 1, 1); gtk_button_set_relief(GTK_BUTTON(button_bookmarks), GTK_RELIEF_HALF); #ifdef HAVE_GTK_320 gtk_widget_set_focus_on_click(GTK_WIDGET(button_bookmarks), FALSE); #else gtk_button_set_focus_on_click(GTK_BUTTON(button_bookmarks), FALSE); #endif button_search = gtk_toggle_button_new_with_mnemonic(_("Search")); gtk_widget_show(button_search); gtk_grid_attach(GTK_GRID(table2), button_search, 0, 1, 1, 1); gtk_button_set_relief(GTK_BUTTON(button_search), GTK_RELIEF_HALF); #ifdef HAVE_GTK_320 gtk_widget_set_focus_on_click(GTK_WIDGET(button_search), FALSE); #else gtk_button_set_focus_on_click(GTK_BUTTON(button_search), FALSE); #endif button_v_lists = gtk_toggle_button_new_with_mnemonic(_("Verse List")); gtk_widget_show(button_v_lists); gtk_grid_attach(GTK_GRID(table2), button_v_lists, 1, 1, 1, 1); gtk_button_set_relief(GTK_BUTTON(button_v_lists), GTK_RELIEF_HALF); #ifdef HAVE_GTK_320 gtk_widget_set_focus_on_click(GTK_WIDGET(button_v_lists), FALSE); #else gtk_button_set_focus_on_click(GTK_BUTTON(button_v_lists), FALSE); #endif button_modules = gtk_toggle_button_new_with_mnemonic(_("Modules")); gtk_widget_show(button_modules); gtk_grid_attach(GTK_GRID(table2), button_modules, 0, 0, 1, 1); gtk_button_set_relief(GTK_BUTTON(button_modules), GTK_RELIEF_HALF); #ifdef HAVE_GTK_320 gtk_widget_set_focus_on_click(GTK_WIDGET(button_modules), FALSE); #else gtk_button_set_focus_on_click(GTK_BUTTON(button_modules), FALSE); #endif #else table2 = gtk_table_new(2, 2, TRUE); gtk_widget_show(table2); gtk_box_pack_start(GTK_BOX(vbox1), table2, FALSE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(table2), 2); gtk_table_set_row_spacings(GTK_TABLE(table2), 6); gtk_table_set_col_spacings(GTK_TABLE(table2), 6); button_bookmarks = gtk_toggle_button_new_with_mnemonic(_("Bookmarks")); gtk_widget_show(button_bookmarks); gtk_table_attach(GTK_TABLE(table2), button_bookmarks, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_button_set_relief(GTK_BUTTON(button_bookmarks), GTK_RELIEF_HALF); gtk_button_set_focus_on_click(GTK_BUTTON(button_bookmarks), FALSE); button_search = gtk_toggle_button_new_with_mnemonic(_("Search")); gtk_widget_show(button_search); gtk_table_attach(GTK_TABLE(table2), button_search, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_button_set_relief(GTK_BUTTON(button_search), GTK_RELIEF_HALF); gtk_button_set_focus_on_click(GTK_BUTTON(button_search), FALSE); button_v_lists = gtk_toggle_button_new_with_mnemonic(_("Verse List")); gtk_widget_show(button_v_lists); gtk_table_attach(GTK_TABLE(table2), button_v_lists, 1, 2, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_button_set_relief(GTK_BUTTON(button_v_lists), GTK_RELIEF_HALF); gtk_button_set_focus_on_click(GTK_BUTTON(button_v_lists), FALSE); button_modules = gtk_toggle_button_new_with_mnemonic(_("Modules")); gtk_widget_show(button_modules); gtk_table_attach(GTK_TABLE(table2), button_modules, 0, 1, 0, 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_button_set_relief(GTK_BUTTON(button_modules), GTK_RELIEF_HALF); gtk_button_set_focus_on_click(GTK_BUTTON(button_modules), FALSE); #endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_modules), TRUE); /* ---------------------------------------------------------------- */ widgets.notebook_sidebar = gtk_notebook_new(); gtk_widget_show(widgets.notebook_sidebar); gtk_box_pack_start(GTK_BOX(vbox1), widgets.notebook_sidebar, TRUE, TRUE, 0); gtk_widget_set_can_default(widgets.notebook_sidebar, 1); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widgets.notebook_sidebar), FALSE); gtk_notebook_set_show_border(GTK_NOTEBOOK(widgets.notebook_sidebar), FALSE); gtk_container_set_border_width(GTK_CONTAINER(widgets.notebook_sidebar), 2); scrolledwindow4 = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow4); gtk_container_add(GTK_CONTAINER(widgets.notebook_sidebar), scrolledwindow4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow4), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *) scrolledwindow4, settings.shadow_type); sidebar.module_list = gtk_tree_view_new(); gtk_widget_show(sidebar.module_list); gtk_container_add(GTK_CONTAINER(scrolledwindow4), sidebar.module_list); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(sidebar.module_list), FALSE); main_create_pixbufs(); main_add_mod_tree_columns(GTK_TREE_VIEW(sidebar.module_list)); scrolledwindow_bm = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow_bm); gtk_container_add(GTK_CONTAINER(widgets.notebook_sidebar), scrolledwindow_bm); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_bm), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *) scrolledwindow_bm, settings.shadow_type); widgets.bookmark_tree = gui_create_bookmark_tree(); gtk_widget_show(widgets.bookmark_tree); gtk_container_add(GTK_CONTAINER(scrolledwindow_bm), widgets.bookmark_tree); gui_create_search_sidebar(); create_search_results_page(widgets.notebook_sidebar); main_load_module_tree(sidebar.module_list); g_signal_connect_after((gpointer)sidebar.module_list, "button_release_event", G_CALLBACK(on_modules_list_button_release), NULL); // sidebar.menu_modules = create_menu_modules(); sidebar.menu_prayerlist = create_menu_prayerlist(); sidebar.menu_prayerlist_mod = create_menu_prayerlist_mod(); g_signal_connect((gpointer)button_bookmarks, "toggled", G_CALLBACK(on_bookmarks_activate), NULL); g_signal_connect((gpointer)button_search, "toggled", G_CALLBACK(on_search_activate), NULL); g_signal_connect((gpointer)button_v_lists, "toggled", G_CALLBACK(on_search_results_activate), NULL); g_signal_connect((gpointer)button_modules, "toggled", G_CALLBACK(on_modules_activate), NULL); g_signal_connect((gpointer)widgets.notebook_sidebar, "switch-page", G_CALLBACK(on_notebook_switch_page), title_label); return vbox1; }
GtkWidget* create_shellexec_conf_dialog (void) { GtkWidget *shellexec_conf_dialog; GtkWidget *dialog_vbox; GtkWidget *hbox1; GtkWidget *add_button; GtkWidget *remove_button; GtkWidget *edit_button; GtkWidget *scrolledwindow; GtkWidget *command_treeview; GtkWidget *dialog_action_area; GtkWidget *save_button; shellexec_conf_dialog = gtk_dialog_new (); gtk_container_set_border_width (GTK_CONTAINER (shellexec_conf_dialog), 12); gtk_window_set_title (GTK_WINDOW (shellexec_conf_dialog), _("Custom Shell Commands")); gtk_window_set_type_hint (GTK_WINDOW (shellexec_conf_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator (GTK_DIALOG (shellexec_conf_dialog), FALSE); dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (shellexec_conf_dialog)); gtk_widget_show (dialog_vbox); hbox1 = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (dialog_vbox), hbox1, FALSE, TRUE, 0); add_button = gtk_button_new_with_mnemonic (_("Add")); gtk_widget_show (add_button); gtk_box_pack_start (GTK_BOX (hbox1), add_button, TRUE, TRUE, 0); remove_button = gtk_button_new_with_mnemonic (_("Remove")); gtk_widget_show (remove_button); gtk_box_pack_start (GTK_BOX (hbox1), remove_button, TRUE, TRUE, 0); edit_button = gtk_button_new_with_mnemonic (_("Edit")); gtk_widget_show (edit_button); gtk_box_pack_start (GTK_BOX (hbox1), edit_button, TRUE, TRUE, 0); scrolledwindow = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow); gtk_box_pack_end (GTK_BOX (dialog_vbox), scrolledwindow, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_SHADOW_IN); command_treeview = gtk_tree_view_new (); gtk_widget_show (command_treeview); gtk_container_add (GTK_CONTAINER (scrolledwindow), command_treeview); dialog_action_area = gtk_dialog_get_action_area (GTK_DIALOG (shellexec_conf_dialog)); gtk_widget_show (dialog_action_area); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area), GTK_BUTTONBOX_END); save_button = gtk_button_new_with_mnemonic (_("Close")); gtk_widget_show (save_button); gtk_dialog_add_action_widget (GTK_DIALOG (shellexec_conf_dialog), save_button, 0); gtk_widget_set_can_default(save_button, TRUE); g_signal_connect ((gpointer) add_button, "clicked", G_CALLBACK (on_add_button_clicked), NULL); g_signal_connect ((gpointer) remove_button, "clicked", G_CALLBACK (on_remove_button_clicked), NULL); g_signal_connect ((gpointer) edit_button, "clicked", G_CALLBACK (on_edit_button_clicked), NULL); g_signal_connect ((gpointer) save_button, "clicked", G_CALLBACK (on_save_button_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_dialog, shellexec_conf_dialog, "shellexec_conf_dialog"); GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_dialog, dialog_vbox, "dialog_vbox"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, hbox1, "hbox1"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, add_button, "add_button"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, remove_button, "remove_button"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, edit_button, "edit_button"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, scrolledwindow, "scrolledwindow"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, command_treeview, "command_treeview"); GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_dialog, dialog_action_area, "dialog_action_area"); GLADE_HOOKUP_OBJECT (shellexec_conf_dialog, save_button, "save_button"); return shellexec_conf_dialog; }
GtkWidget* create_shellexec_conf_edit_dialog (void) { GtkWidget *shellexec_conf_edit_dialog; GtkWidget *dialog_vbox1; GtkWidget *table1; GtkWidget *title_label; GtkWidget *cmd_label; GtkWidget *cmd_entry; GtkWidget *name_label; GtkWidget *title_entry; GtkWidget *name_entry; GtkWidget *single_check; GtkWidget *multiple_check; GtkWidget *local_check; GtkWidget *remote_check; GtkWidget *playlist_check; GtkWidget *common_check; GtkWidget *dialog_action_area1; GtkWidget *edit_cancel_button; GtkWidget *edit_ok_button; shellexec_conf_edit_dialog = gtk_dialog_new (); gtk_container_set_border_width (GTK_CONTAINER (shellexec_conf_edit_dialog), 12); gtk_window_set_title (GTK_WINDOW (shellexec_conf_edit_dialog), _("Edit Command")); gtk_window_set_modal (GTK_WINDOW (shellexec_conf_edit_dialog), TRUE); gtk_window_set_type_hint (GTK_WINDOW (shellexec_conf_edit_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_dialog_set_has_separator (GTK_DIALOG (shellexec_conf_edit_dialog), FALSE); dialog_vbox1 = gtk_dialog_get_content_area (GTK_DIALOG (shellexec_conf_edit_dialog)); gtk_widget_show (dialog_vbox1); table1 = gtk_table_new (3, 2, FALSE); gtk_widget_show (table1); gtk_box_pack_start (GTK_BOX (dialog_vbox1), table1, FALSE, TRUE, 0); gtk_table_set_row_spacings (GTK_TABLE (table1), 8); gtk_table_set_col_spacings (GTK_TABLE (table1), 8); title_label = gtk_label_new (_("Title:")); gtk_widget_show (title_label); gtk_table_attach (GTK_TABLE (table1), title_label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0.5); cmd_label = gtk_label_new (_("Command:")); gtk_widget_show (cmd_label); gtk_table_attach (GTK_TABLE (table1), cmd_label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (cmd_label), 0, 0.5); cmd_entry = gtk_entry_new (); gtk_widget_show (cmd_entry); gtk_table_attach (GTK_TABLE (table1), cmd_entry, 1, 2, 2, 3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_widget_set_tooltip_text (cmd_entry, _("Arbitrary shell command. Will be executed in the shell context which the main application was started from. Title formatting can be used. Example: xdg-open %D")); gtk_entry_set_invisible_char (GTK_ENTRY (cmd_entry), 8226); name_label = gtk_label_new (_("ID:")); gtk_widget_show (name_label); gtk_table_attach (GTK_TABLE (table1), name_label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_misc_set_alignment (GTK_MISC (name_label), 0, 0.5); title_entry = gtk_entry_new (); gtk_widget_show (title_entry); gtk_table_attach (GTK_TABLE (table1), title_entry, 1, 2, 1, 2, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_widget_set_tooltip_text (title_entry, _("Free-form name, for example \"My Shell Command\"")); gtk_entry_set_invisible_char (GTK_ENTRY (title_entry), 8226); name_entry = gtk_entry_new (); gtk_widget_show (name_entry); gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_widget_set_tooltip_text (name_entry, _("Command ID, normally it should be something short, for example \"youtube_open\". It must be unique.")); gtk_entry_set_invisible_char (GTK_ENTRY (name_entry), 8226); single_check = gtk_check_button_new_with_mnemonic (_("Single Tracks")); gtk_widget_show (single_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), single_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (single_check, _("Works on single track.")); multiple_check = gtk_check_button_new_with_mnemonic (_("Multiple Tracks")); gtk_widget_show (multiple_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), multiple_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (multiple_check, _("Works on multiple tracks.")); local_check = gtk_check_button_new_with_mnemonic (_("Local")); gtk_widget_show (local_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), local_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (local_check, _("Works on local files.")); remote_check = gtk_check_button_new_with_mnemonic (_("Remote")); gtk_widget_show (remote_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), remote_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (remote_check, _("Works on remote files (e.g. http:// streams)")); playlist_check = gtk_check_button_new_with_mnemonic (_("Playlist")); gtk_widget_show (playlist_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), playlist_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (playlist_check, _("Item should appear on the playlist tab context menu")); common_check = gtk_check_button_new_with_mnemonic (_("Common")); gtk_widget_show (common_check); gtk_box_pack_start (GTK_BOX (dialog_vbox1), common_check, FALSE, FALSE, 0); gtk_widget_set_tooltip_text (common_check, _("Item should appear in the main menu")); dialog_action_area1 = gtk_dialog_get_action_area (GTK_DIALOG (shellexec_conf_edit_dialog)); gtk_widget_show (dialog_action_area1); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END); edit_cancel_button = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (edit_cancel_button); gtk_dialog_add_action_widget (GTK_DIALOG (shellexec_conf_edit_dialog), edit_cancel_button, GTK_RESPONSE_CANCEL); gtk_widget_set_can_default(edit_cancel_button, TRUE); edit_ok_button = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (edit_ok_button); gtk_dialog_add_action_widget (GTK_DIALOG (shellexec_conf_edit_dialog), edit_ok_button, GTK_RESPONSE_OK); gtk_widget_set_can_default(edit_ok_button, TRUE); g_signal_connect ((gpointer) edit_cancel_button, "clicked", G_CALLBACK (on_edit_cancel_button_clicked), NULL); g_signal_connect ((gpointer) edit_ok_button, "clicked", G_CALLBACK (on_edit_ok_button_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_edit_dialog, shellexec_conf_edit_dialog, "shellexec_conf_edit_dialog"); GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_edit_dialog, dialog_vbox1, "dialog_vbox1"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, table1, "table1"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, title_label, "title_label"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, cmd_label, "cmd_label"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, cmd_entry, "cmd_entry"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, name_label, "name_label"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, title_entry, "title_entry"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, name_entry, "name_entry"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, single_check, "single_check"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, multiple_check, "multiple_check"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, local_check, "local_check"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, remote_check, "remote_check"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, playlist_check, "playlist_check"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, common_check, "common_check"); GLADE_HOOKUP_OBJECT_NO_REF (shellexec_conf_edit_dialog, dialog_action_area1, "dialog_action_area1"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, edit_cancel_button, "edit_cancel_button"); GLADE_HOOKUP_OBJECT (shellexec_conf_edit_dialog, edit_ok_button, "edit_ok_button"); return shellexec_conf_edit_dialog; }