static GtkWidget * revert_dialog (CeditWindow *window, CeditDocument *doc) { GtkWidget *dialog; gchar *docname; gchar *primary_msg; gchar *secondary_msg; glong seconds; cedit_debug (DEBUG_COMMANDS); docname = cedit_document_get_short_name_for_display (doc); primary_msg = g_strdup_printf (_("Revert unsaved changes to document '%s'?"), docname); g_free (docname); seconds = MAX (1, _cedit_document_get_seconds_since_last_save_or_load (doc)); if (seconds < 55) { secondary_msg = g_strdup_printf ( ngettext ("Changes made to the document in the last %ld second " "will be permanently lost.", "Changes made to the document in the last %ld seconds " "will be permanently lost.", seconds), seconds); } else if (seconds < 75) /* 55 <= seconds < 75 */ { secondary_msg = g_strdup (_("Changes made to the document in the last minute " "will be permanently lost.")); } else if (seconds < 110) /* 75 <= seconds < 110 */ { secondary_msg = g_strdup_printf ( ngettext ("Changes made to the document in the last minute and " "%ld second will be permanently lost.", "Changes made to the document in the last minute and " "%ld seconds will be permanently lost.", seconds - 60 ), seconds - 60); } else if (seconds < 3600) { secondary_msg = g_strdup_printf ( ngettext ("Changes made to the document in the last %ld minute " "will be permanently lost.", "Changes made to the document in the last %ld minutes " "will be permanently lost.", seconds / 60), seconds / 60); } else if (seconds < 7200) { gint minutes; seconds -= 3600; minutes = seconds / 60; if (minutes < 5) { secondary_msg = g_strdup (_("Changes made to the document in the last hour " "will be permanently lost.")); } else { secondary_msg = g_strdup_printf ( ngettext ("Changes made to the document in the last hour and " "%d minute will be permanently lost.", "Changes made to the document in the last hour and " "%d minutes will be permanently lost.", minutes), minutes); } } else { gint hours; hours = seconds / 3600; secondary_msg = g_strdup_printf ( ngettext ("Changes made to the document in the last %d hour " "will be permanently lost.", "Changes made to the document in the last %d hours " "will be permanently lost.", hours), hours); } dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", primary_msg); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_msg); g_free (primary_msg); g_free (secondary_msg); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); cedit_dialog_add_button (GTK_DIALOG (dialog), _("_Revert"), GTK_STOCK_REVERT_TO_SAVED, GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL); return dialog; }
static void prefs_actions_create(MainWindow *mainwin) { GtkWidget *window; GtkWidget *vbox; GtkWidget *filter_hbox; GtkWidget *help_btn; GtkWidget *ok_btn; GtkWidget *cancel_btn; GtkWidget *confirm_area; GtkWidget *vbox1; GtkWidget *table; GtkWidget *shell_radiobtn; GtkWidget *filter_radiobtn; GtkWidget *name_label; GtkWidget *name_entry; GtkWidget *cmd_label; GtkWidget *cmd_entry; GtkWidget *filter_btn; GtkWidget *reg_hbox; GtkWidget *btn_hbox; GtkWidget *arrow; GtkWidget *reg_btn; GtkWidget *subst_btn; GtkWidget *del_btn; GtkWidget *clear_btn; GtkWidget *cond_hbox; GtkWidget *cond_scrolledwin; GtkWidget *cond_list_view; GtkWidget *info_btn; GtkWidget *btn_vbox; GtkWidget *up_btn; GtkWidget *down_btn; static GdkGeometry geometry; debug_print("Creating actions configuration window...\n"); window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_actions"); gtk_container_set_border_width(GTK_CONTAINER (window), 8); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(window), TRUE); vbox = gtk_vbox_new(FALSE, 6); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(window), vbox); gtkut_stock_button_set_create_with_help(&confirm_area, &help_btn, &cancel_btn, GTK_STOCK_CANCEL, &ok_btn, GTK_STOCK_OK, NULL, NULL); gtk_widget_show(confirm_area); gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0); gtk_widget_grab_default(ok_btn); gtk_window_set_title(GTK_WINDOW(window), _("Actions configuration")); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(prefs_actions_deleted), NULL); g_signal_connect(G_OBJECT(window), "size_allocate", G_CALLBACK(prefs_actions_size_allocate_cb), NULL); g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(prefs_actions_key_pressed), NULL); MANAGE_WINDOW_SIGNALS_CONNECT(window); g_signal_connect(G_OBJECT(ok_btn), "clicked", G_CALLBACK(prefs_actions_ok), mainwin); g_signal_connect(G_OBJECT(cancel_btn), "clicked", G_CALLBACK(prefs_actions_cancel), NULL); g_signal_connect(G_OBJECT(help_btn), "clicked", G_CALLBACK(manual_open_with_anchor_cb), MANUAL_ANCHOR_ACTIONS); vbox1 = gtk_vbox_new(FALSE, VSPACING); gtk_widget_show(vbox1); gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2); table = gtk_table_new(3, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_widget_show(table); gtk_box_pack_start (GTK_BOX (vbox1), table, FALSE, FALSE, 0); name_label = gtk_label_new (_("Menu name")); gtk_widget_show (name_label); gtk_misc_set_alignment (GTK_MISC (name_label), 1, 0.5); gtk_table_attach (GTK_TABLE (table), name_label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); name_entry = gtk_entry_new (); gtk_widget_show (name_entry); gtk_table_attach (GTK_TABLE (table), name_entry, 1, 2, 0, 1, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); cmd_label = gtk_label_new (_("Command")); gtk_widget_show (cmd_label); gtk_misc_set_alignment (GTK_MISC (cmd_label), 1, 0.5); gtk_table_attach (GTK_TABLE (table), cmd_label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); cmd_entry = gtk_entry_new (); gtk_widget_show (cmd_entry); gtk_table_attach (GTK_TABLE (table), cmd_entry, 1, 2, 2, 3, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); /* radio buttons for filter actions or shell */ filter_hbox = gtk_hbox_new(FALSE,4); gtk_table_attach(GTK_TABLE(table), filter_hbox, 1, 2, 3, 4, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (0), 0, 0); gtk_widget_show(filter_hbox); shell_radiobtn = gtk_radio_button_new_with_label(NULL, _("Shell command")); gtk_box_pack_start(GTK_BOX(filter_hbox), shell_radiobtn, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shell_radiobtn), TRUE); gtk_widget_show(shell_radiobtn); g_signal_connect(G_OBJECT(shell_radiobtn), "clicked", G_CALLBACK(prefs_action_shell_radiobtn_cb), NULL); filter_radiobtn = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(shell_radiobtn), _("Filter action")); gtk_box_pack_start(GTK_BOX(filter_hbox), filter_radiobtn, FALSE, FALSE, 0); gtk_widget_show(filter_radiobtn); g_signal_connect(G_OBJECT(filter_radiobtn), "clicked", G_CALLBACK(prefs_action_filter_radiobtn_cb), NULL); filter_btn = gtk_button_new_with_label(_("Edit filter action")); gtk_box_pack_start(GTK_BOX(filter_hbox), filter_btn, FALSE, FALSE, 0); gtk_widget_set_sensitive(filter_btn, FALSE); g_signal_connect(G_OBJECT(filter_btn), "clicked", G_CALLBACK(prefs_action_filterbtn_cb), NULL); gtk_widget_show(filter_btn); /* register / substitute / delete */ reg_hbox = gtk_hbox_new(FALSE, 4); gtk_widget_show(reg_hbox); gtk_box_pack_start(GTK_BOX(vbox1), reg_hbox, FALSE, FALSE, 0); arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT); gtk_widget_show(arrow); gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0); gtk_widget_set_size_request(arrow, -1, 16); btn_hbox = gtk_hbox_new(TRUE, 4); gtk_widget_show(btn_hbox); gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0); reg_btn = gtk_button_new_from_stock(GTK_STOCK_ADD); gtk_widget_show(reg_btn); gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(reg_btn), "clicked", G_CALLBACK(prefs_actions_register_cb), NULL); CLAWS_SET_TIP(reg_btn, _("Append the new action above to the list")); subst_btn = gtkut_get_replace_btn(_("_Replace")); gtk_widget_show(subst_btn); gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(subst_btn), "clicked", G_CALLBACK(prefs_actions_substitute_cb), NULL); CLAWS_SET_TIP(subst_btn, _("Replace the selected action in list with the action above")); del_btn = gtk_button_new_with_mnemonic (_("D_elete")); gtk_button_set_image(GTK_BUTTON(del_btn), gtk_image_new_from_stock(GTK_STOCK_REMOVE,GTK_ICON_SIZE_BUTTON)); gtk_widget_show(del_btn); gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(del_btn), "clicked", G_CALLBACK(prefs_actions_delete_cb), NULL); CLAWS_SET_TIP(del_btn, _("Delete the selected action from the list")); clear_btn = gtk_button_new_with_mnemonic (_("C_lear")); gtk_button_set_image(GTK_BUTTON(clear_btn), gtk_image_new_from_stock(GTK_STOCK_CLEAR,GTK_ICON_SIZE_BUTTON)); gtk_widget_show (clear_btn); gtk_box_pack_start (GTK_BOX (btn_hbox), clear_btn, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (clear_btn), "clicked", G_CALLBACK(prefs_actions_clear_cb), NULL); CLAWS_SET_TIP(clear_btn, _("Clear all the input fields in the dialog")); info_btn = gtk_button_new_from_stock(GTK_STOCK_INFO); gtk_widget_show(info_btn); gtk_box_pack_end(GTK_BOX(reg_hbox), info_btn, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(info_btn), "clicked", G_CALLBACK(prefs_actions_info_cb), GTK_WINDOW(window)); CLAWS_SET_TIP(info_btn, _("Show information on configuring actions")); cond_hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show(cond_hbox); gtk_box_pack_start(GTK_BOX(vbox1), cond_hbox, TRUE, TRUE, 0); cond_scrolledwin = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(cond_scrolledwin); gtk_widget_set_size_request(cond_scrolledwin, -1, 150); gtk_box_pack_start(GTK_BOX(cond_hbox), cond_scrolledwin, TRUE, TRUE, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (cond_scrolledwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(cond_scrolledwin), GTK_SHADOW_ETCHED_IN); cond_list_view = prefs_actions_list_view_create(); gtk_widget_show(cond_list_view); gtk_container_add(GTK_CONTAINER (cond_scrolledwin), cond_list_view); btn_vbox = gtk_vbox_new(FALSE, 8); gtk_widget_show(btn_vbox); gtk_box_pack_start(GTK_BOX(cond_hbox), btn_vbox, FALSE, FALSE, 0); up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP); gtk_widget_show(up_btn); gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(up_btn), "clicked", G_CALLBACK(prefs_actions_up), NULL); CLAWS_SET_TIP(up_btn, _("Move the selected action up")); down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); gtk_widget_show(down_btn); gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(down_btn), "clicked", G_CALLBACK(prefs_actions_down), NULL); CLAWS_SET_TIP(down_btn, _("Move selected action down")); if (!geometry.min_height) { geometry.min_width = 486; geometry.min_height = 322; } gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry, GDK_HINT_MIN_SIZE); gtk_widget_set_size_request(window, prefs_common.actionswin_width, prefs_common.actionswin_height); gtk_widget_show(window); actions.window = window; actions.ok_btn = ok_btn; actions.info_btn = info_btn; actions.name_entry = name_entry; actions.cmd_entry = cmd_entry; actions.filter_btn = filter_btn; actions.shell_radiobtn = shell_radiobtn; actions.filter_radiobtn = filter_radiobtn; actions.actions_list_view = cond_list_view; }
int main(int argc, char **argv) { if (argc == 2 && 0 == g_strcmp0(argv[1], "-d")) g_setenv("G_MESSAGES_DEBUG", "all", FALSE); GOptionContext *context = g_option_context_new("- Deepin Installer"); g_option_context_add_main_entries(context, entries, "INSTALLER"); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, NULL)) { g_warning ("context parse failed\n"); } if (auto_conf_path != NULL && !g_file_test(auto_conf_path, G_FILE_TEST_IS_REGULAR)) { g_warning("the configure is valid: %s", auto_conf_path); exit(1); } g_option_context_free(context); redirect_log(log_path); gtk_init (&argc, &argv); setlocale(LC_MESSAGES, ""); textdomain("INSTALLER"); if (geteuid () != 0) { g_warning ("must run installer as root\n"); exit (0); } if (installer_is_running ()) { g_warning ("another instance of installer is running\n"); exit (0); } signal (SIGTERM, sigterm_cb); signal (SIGINT, sigterm_cb); signal (SIGQUIT, sigterm_cb); signal (SIGKILL, sigterm_cb); signal (SIGTSTP, sigterm_cb); installer_container = create_web_container (FALSE, TRUE); gtk_window_set_decorated (GTK_WINDOW (installer_container), FALSE); GtkWidget *webview = d_webview_new_with_uri (INSTALLER_HTML_PATH); g_signal_connect (webview, "draw", G_CALLBACK (erase_background), NULL); gtk_container_add (GTK_CONTAINER (installer_container), GTK_WIDGET (webview)); WebKitWebSettings *setting = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webview)); g_object_set(G_OBJECT(setting), "enable-default-context-menu", FALSE, NULL); if (nowm) { fix_without_wm(webview); } else { g_signal_connect (installer_container, "button-press-event", G_CALLBACK (move_window), NULL); gtk_window_set_position (GTK_WINDOW (installer_container), GTK_WIN_POS_CENTER); } gtk_window_set_default_size (GTK_WINDOW (installer_container), INSTALLER_WIN_WIDTH, INSTALLER_WIN_HEIGHT); gtk_window_set_resizable (GTK_WINDOW (installer_container), FALSE); GdkGeometry geometry; geometry.min_width = INSTALLER_WIN_WIDTH; geometry.max_width = INSTALLER_WIN_WIDTH; geometry.base_width = INSTALLER_WIN_WIDTH; geometry.min_height = INSTALLER_WIN_HEIGHT; geometry.max_height = INSTALLER_WIN_HEIGHT; geometry.base_height = INSTALLER_WIN_HEIGHT; gtk_window_set_geometry_hints (GTK_WINDOW (installer_container), webview, &geometry, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE); gtk_widget_show_all (installer_container); /*#ifndef NDEBUG*/ /*monitor_resource_file("installer", webview);*/ /*#endif*/ gtk_main (); return 0; }
/* * Move entry * Signal handler for "activate" move entry */ gboolean move_entry() { FILE *fp = NULL; GtkWidget *msg_dialog = NULL; GtkWidget *section_dialog = NULL; GtkWidget *section_view = NULL; GtkTreeModel *section_model = NULL; GtkTreeSelection *section_selection = NULL; GtkTreeIter section_iter; gchar entry_display_name[MAX_NAME_LEN]; gchar curr_entry_path[MAX_PATH_LEN]; gchar move_entry_path[MAX_PATH_LEN]; GList *entry_item = NULL; book_data *book = NULL; section_data *section = NULL; entry_data *entry = NULL; book_data *book_copy = NULL; section_data *section_copy = NULL; gint result; // Assert master exists g_assert_nonnull(master); // Get currently selected book = get_current_book_or_return_with_warning(); section = get_current_section_or_return_with_warning(); entry = get_current_entry_or_return_with_warning(); // Create section view section_view = gtk_tree_view_new(); // Create section dialog section_dialog = create_book_section_dialog(section_view, "Select the section to move the entry to..."); // Init section view init_book_section_view(GTK_TREE_VIEW(section_view)); // Create section entry model / store section_model = create_book_section_model(master); // Set section model on section view gtk_tree_view_set_model(GTK_TREE_VIEW(section_view), GTK_TREE_MODEL(section_model)); if(section_model != NULL) g_object_unref(section_model); // Show and run view section dialog gtk_widget_show_all(section_dialog); result = gtk_dialog_run(GTK_DIALOG(section_dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: section_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(section_view)); if(gtk_tree_selection_get_selected(section_selection, §ion_model, §ion_iter)) { gtk_tree_model_get(section_model, §ion_iter, SECTION_ITEM, §ion_copy, END_OF_LIST); if(section == NULL) { gtk_widget_destroy(section_dialog); return FALSE; } } else { gtk_widget_destroy(section_dialog); return FALSE; } book_copy = section_copy->parent_book; // Curr entry file path g_snprintf(curr_entry_path, sizeof(curr_entry_path), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, section->name, G_DIR_SEPARATOR_S, entry->name); // Move entry file path g_snprintf(move_entry_path, sizeof(move_entry_path), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book_copy->name, G_DIR_SEPARATOR_S, section_copy->name, G_DIR_SEPARATOR_S, entry->name); // Set display name strncpy(entry_display_name, entry->name, MAX_NAME_LEN-5); if(strlen(entry_display_name) > 25) strcpy(entry_display_name+25, "...\0"); // Check that new entry path is valid fp = fopen(move_entry_path, "wx"); if (fp == NULL) { sn_warning("Unable to move entry [%s].", move_entry_path); msg_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to move entry \"%s\".", entry_display_name); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), "Please ensure the entry name doesn't aleady exist."); gtk_window_set_title(GTK_WINDOW(msg_dialog), app_name); gtk_window_set_type_hint(GTK_WINDOW(msg_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(msg_dialog), FALSE); result = gtk_dialog_run(GTK_DIALOG(msg_dialog)); gtk_widget_destroy(msg_dialog); gtk_widget_destroy(section_dialog); return FALSE; } fclose(fp); // Remove file created by previous open result = remove(move_entry_path); sn_trace("Moving entry [%s] to [%s].", curr_entry_path, move_entry_path); // Move the entry file to the new path result = rename(curr_entry_path, move_entry_path); if(result == 0) { // Remove history remove_history(); // Select next entry entry_item = g_list_find(section->entry_list, entry); entry_item = entry_item->next; if(entry_item != NULL) section->curr_entry = entry_item->data; else section->curr_entry = NULL; // Remove entry section->entry_list = g_list_remove(section->entry_list, entry); // Append entry section_copy->entry_list = g_list_append(section_copy->entry_list, entry); // Update entry entry->parent_section = section_copy; // Write book write_book(book, note_dir); // Update view populate_entries(book, section); gtk_widget_destroy(section_dialog); return TRUE; } else { gtk_widget_destroy(section_dialog); sn_warning("Unable to move entry [%s].", curr_entry_path); return FALSE; } gtk_widget_destroy(section_dialog); return FALSE; default: gtk_widget_destroy(section_dialog); return FALSE; } // End switch return FALSE; } // Move entry
static void expanded( GtkExpander *expander, GParamSpec *ps, GtkWindow *window ) { gtk_window_set_resizable( window, gtk_expander_get_expanded( expander ) ); }
void main_gui(int argc, char **argv) { /* inits */ gdk_threads_init(); gdk_threads_enter(); gtk_init (&argc, &argv); pthread_mutex_init(&mutex_guichange, NULL); /* window */ gres.window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(gres.window), 0); gtk_window_set_urgency_hint (GTK_WINDOW(gres.window), TRUE); gtk_window_set_title (GTK_WINDOW (gres.window), _PROJECTNAME); gtk_window_set_default_size(GTK_WINDOW(gres.window), 800, 600); gtk_window_set_position(GTK_WINDOW(gres.window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(gres.window), TRUE); /* setting window icon */ gtk_window_set_icon(GTK_WINDOW(gres.window), create_pixbuf(GUI_ICON)); gtk_widget_show(gres.window); g_signal_connect(G_OBJECT(gres.window), "delete_event", G_CALLBACK(on_destroy), NULL); g_signal_connect(G_OBJECT(gres.window), "destroy", G_CALLBACK(on_destroy), NULL); /* vbox principale */ gres.vbox_main = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1); gtk_container_add(GTK_CONTAINER(gres.window), gres.vbox_main); gtk_container_set_border_width(GTK_CONTAINER(gres.vbox_main),0); /* accellgroup */ gres.accel_group = gtk_accel_group_new(); gtk_window_add_accel_group(GTK_WINDOW(gres.window), gres.accel_group); /* menubar */ gres.menubar = gtk_menu_bar_new(); gres.filemenu = gtk_menu_new(); gres.helpmenu = gtk_menu_new(); gres.file = gtk_menu_item_new_with_label("File"); //gres.connect = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL); gres.open = gtk_image_menu_item_new_from_stock(GTK_STOCK_OPEN, NULL); gres.font = gtk_image_menu_item_new_from_stock(GTK_STOCK_SELECT_FONT, NULL); gres.sep = gtk_separator_menu_item_new(); gres.quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, gres.accel_group); gres.help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, NULL); gres.about = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.file), gres.filemenu); //gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.connect); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.font); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.sep); gtk_menu_shell_append(GTK_MENU_SHELL(gres.filemenu), gres.quit); gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.file); gtk_menu_item_set_submenu(GTK_MENU_ITEM(gres.help), gres.helpmenu); gtk_menu_shell_append(GTK_MENU_SHELL(gres.helpmenu), gres.about); gtk_menu_shell_append(GTK_MENU_SHELL(gres.menubar), gres.help); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.menubar, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(gres.quit), "activate", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(gres.font), "activate", G_CALLBACK(select_font), G_OBJECT(gres.window)); g_signal_connect(G_OBJECT(gres.about), "activate", G_CALLBACK(show_about), NULL); /* toolbar */ gres.toolbar = gtk_toolbar_new(); gtk_toolbar_set_style(GTK_TOOLBAR(gres.toolbar), GTK_TOOLBAR_BOTH); gtk_container_set_border_width(GTK_CONTAINER(gres.toolbar), 2); gres.toolbar_connect = gtk_tool_button_new_from_stock(GTK_STOCK_NETWORK); if (!c_core->GetSession()->IsConnected()) gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Connect"); else gtk_tool_button_set_label(GTK_TOOL_BUTTON(gres.toolbar_connect), "Disconnect"); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_connect, -1); g_signal_connect(G_OBJECT(gres.toolbar_connect), "clicked", G_CALLBACK(toolbar_connect_click), NULL); //gres.toolbar_refresh = gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); //gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_refresh, -1); //g_signal_connect(G_OBJECT(gres.toolbar_refresh), "clicked", G_CALLBACK(set_nick), G_OBJECT(gres.window)); gres.toolbar_reset = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_reset, -1); g_signal_connect(G_OBJECT(gres.toolbar_reset), "clicked", G_CALLBACK(toolbar_reset_click), NULL); gres.toolbar_separator = gtk_separator_tool_item_new(); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_separator, -1); gres.toolbar_exit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); gtk_toolbar_insert(GTK_TOOLBAR(gres.toolbar), gres.toolbar_exit, -1); g_signal_connect(G_OBJECT(gres.toolbar_exit), "clicked", G_CALLBACK(gtk_main_quit), NULL); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.toolbar, FALSE, FALSE, 0); /* Paned */ gres.paned_main = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start(GTK_BOX(gres.vbox_main), gres.paned_main, TRUE, TRUE, 0); gres.scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL); gtk_paned_pack1 (GTK_PANED(gres.paned_main), gres.scrolledwindow_chat, true, true); gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_chat), 2); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_chat), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gres.view_chat = gtk_text_view_new(); GdkRGBA color; gdk_rgba_parse (&color, CFG_GET_STRING("chat_bg").c_str()); gtk_widget_override_background_color(GTK_WIDGET(gres.view_chat), GTK_STATE_FLAG_NORMAL, &color); PangoFontDescription *font_desc = pango_font_description_from_string(CFG_GET_STRING("chat_font").c_str()); if (font_desc) gtk_widget_modify_font(gres.view_chat, font_desc); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gres.view_chat), GTK_WRAP_WORD_CHAR); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (gres.view_chat), FALSE); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (gres.view_chat), 1); gtk_text_view_set_right_margin (GTK_TEXT_VIEW (gres.view_chat), 1); gtk_text_view_set_editable(GTK_TEXT_VIEW(gres.view_chat), FALSE); gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_chat), gres.view_chat); gres.tbuf_chat = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gres.view_chat)); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_bg", "background", CFG_GET_STRING("chat_bg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_sys_msg_fg", "foreground", CFG_GET_STRING("chat_sys_msg_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_msg_fg", "foreground", CFG_GET_STRING("chat_msg_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_join_fg", "foreground", CFG_GET_STRING("chat_join_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_leave_fg", "foreground", CFG_GET_STRING("chat_leave_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "chat_whisp_fg", "foreground", CFG_GET_STRING("chat_whisp_fg").c_str() , NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "gap", "pixels_above_lines", 30, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "lmarg", "left_margin", 5, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "black_fg", "foreground", "#000000", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "white_fg", "foreground", "#ffffff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_fg", "foreground", "#3200ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_fg", "foreground", "#ff32ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "green_fg", "foreground", "#55ff00", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "red_fg", "foreground", "#ff3200", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "green_bg", "background", "#55ff00", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "blue_bg", "background", "#3200ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "red_bg", "background", "#ff3200", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "yellow_bg", "background", "#f7f732", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "magenta_bg", "background", "#ff32ff", NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "italic", "style", PANGO_STYLE_ITALIC, NULL); gtk_text_buffer_create_tag(gres.tbuf_chat, "bold", "weight", PANGO_WEIGHT_BOLD, NULL); gres.scrolledwindow_user_list = gtk_scrolled_window_new (NULL, NULL); gtk_paned_pack2 (GTK_PANED(gres.paned_main), gres.scrolledwindow_user_list, false, false); gtk_container_set_border_width (GTK_CONTAINER (gres.scrolledwindow_user_list), 2); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gres.scrolledwindow_user_list), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show (gres.scrolledwindow_user_list); gres.model_user_list = gtk_list_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_STRING); gres.view_user_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(gres.model_user_list)); gres.selection_user_list = gtk_tree_view_get_selection(GTK_TREE_VIEW(gres.view_user_list)); gtk_tree_selection_set_mode(gres.selection_user_list, GTK_SELECTION_SINGLE); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(gres.view_user_list), TRUE); gres.renderer_user_list = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list), /* vista */ -1, /* posizione della colonna */ "Name", /* titolo della colonna */ gres.renderer_user_list, /* cella inserita nella colonna */ "text", /* attributo colonna */ COLUMN_STRING1, /* colonna inserita */ NULL); /* fine ;-) */ gres.renderer_user_list = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(gres.view_user_list), -1, "Type", gres.renderer_user_list, "text", COLUMN_STRING2, NULL); gtk_widget_show (gres.view_user_list); g_object_unref(gres.model_user_list); gtk_container_add (GTK_CONTAINER (gres.scrolledwindow_user_list), gres.view_user_list); gtk_container_set_border_width (GTK_CONTAINER (gres.view_user_list), 0); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (gres.view_user_list), TRUE); /* INPUTS */ gres.hbox_inputs = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.hbox_inputs, FALSE, FALSE, 0); gres.label_nick = gtk_label_new((gchar *) CFG_GET_STRING("username").c_str()); gtk_misc_set_alignment(GTK_MISC(gres.label_nick), 0.0, 0.5); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.label_nick, FALSE, FALSE, 2 ); gres.entry_command = gtk_entry_new(); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.entry_command, TRUE, TRUE, 5); gres.button_send = gtk_button_new_with_label("Send"); gtk_widget_set_size_request (GTK_WIDGET (gres.button_send), 70, 30); gtk_box_pack_start(GTK_BOX (gres.hbox_inputs), gres.button_send, FALSE, FALSE, 0); gres.text_entry = gres.entry_command; g_signal_connect(G_OBJECT(gres.entry_command), "activate", G_CALLBACK(button_send_click), NULL); g_signal_connect(G_OBJECT(gres.button_send), "clicked", G_CALLBACK(button_send_click), NULL); /* status_bar */ gres.status_bar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX (gres.vbox_main), gres.status_bar, FALSE, FALSE, 0); /* end_widgets */ gtk_widget_show_all(gres.window); /* default focus on command entry */ gtk_widget_grab_focus (GTK_WIDGET(gres.text_entry)); INFO ("debug", "GUI: starting GUI thread\n"); pthread_t tid; StartThread(GuiThread, (void*)&gres, tid); INFO ("debug", "GUI: starting GTK+3\n"); gtk_main(); gdk_threads_leave(); pthread_mutex_destroy(&mutex_guichange); return; }
/* * Delete entry * Signal handler for "activate" delete entry */ gboolean delete_entry() { GtkWidget *msg_dialog; gchar filename[MAX_PATH_LEN]; gchar entry_display_name[MAX_NAME_LEN]; GList *entry_item = NULL; book_data *book = NULL; section_data *section = NULL; entry_data *entry = NULL; gint result; // Assert master exists g_assert_nonnull(master); // Get currently selected book = get_current_book_or_return_with_warning(); section = get_current_section_or_return_with_warning(); entry = get_current_entry_or_return_with_warning(); // Set display name strncpy(entry_display_name, entry->name, MAX_NAME_LEN-5); if(strlen(entry_display_name) > 25) strcpy(entry_display_name+25, "...\0"); // Confirm delete action msg_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "Are you sure you want to delete\n\"%s\"?", entry_display_name); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), "If you delete an entry, it is permanently lost."); gtk_window_set_title(GTK_WINDOW(msg_dialog), app_name); gtk_window_set_type_hint(GTK_WINDOW(msg_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(msg_dialog), FALSE); result = gtk_dialog_run(GTK_DIALOG(msg_dialog)); switch (result) { case GTK_RESPONSE_YES: // Delete entry text file g_snprintf(filename, sizeof(filename), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, section->name, G_DIR_SEPARATOR_S, entry->name); sn_trace("Deleting entry [%s] in delete_entry().", filename); result = remove(filename); if (result == 0) { // Remove history remove_history(); // Select next entry entry_item = g_list_find(section->entry_list, entry); entry_item = entry_item->next; if(entry_item != NULL) section->curr_entry = entry_item->data; else section->curr_entry = NULL; // Remove entry section->entry_list = g_list_remove(section->entry_list, entry); free_entry(entry); // Write book write_book(book, note_dir); // Update view populate_entries(book, section); gtk_widget_grab_focus(GTK_WIDGET(get_entry_view(book))); gtk_widget_destroy(msg_dialog); return TRUE; } else { sn_warning("Unable to delete entry [%s].", entry->name); gtk_widget_destroy(msg_dialog); return FALSE; } default: gtk_widget_destroy(msg_dialog); return FALSE; } return FALSE; } // Delete entry
GtkWidget *gui_create_about_trans(void) { GtkWidget *dialog_about_trans; GtkWidget *dialog_vbox; GtkWidget *vbox; GtkWidget *pixmap; GtkWidget *scrolledwindow; GtkWidget *label; GtkWidget *textview; GtkWidget *href; GtkWidget *dialog_action_area; GtkWidget *hbuttonbox; GtkWidget *button; gchar *about = _("Do you like using Xiphos to study the Bible? " "Would you like to see its user interface in your native language? " "You could translate Xiphos! " "\n\n" "We are always looking for contributions of new " "translations of Xiphos into other languages. " "If you are able to translate for us, please see the link " "below, contact us, and get involved with our efforts. Your help will " "be much appreciated!"); dialog_about_trans = gtk_dialog_new(); g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_about_trans", dialog_about_trans); gtk_window_set_title(GTK_WINDOW(dialog_about_trans), _("About Xiphos Translation")); set_window_icon(GTK_WINDOW(dialog_about_trans)); gtk_window_set_resizable(GTK_WINDOW(dialog_about_trans), FALSE); dialog_vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans)); g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_vbox", dialog_vbox); gtk_widget_show(dialog_vbox); UI_VBOX(vbox, FALSE, 0); gtk_widget_show(vbox); gtk_box_pack_start(GTK_BOX(dialog_vbox), vbox, TRUE, TRUE, 0); pixmap = pixmap_finder("logo.png"); gtk_widget_show(pixmap); gtk_box_pack_start(GTK_BOX(vbox), pixmap, FALSE, FALSE, 4); scrolledwindow = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow); gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 4); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_set_size_request(scrolledwindow, 400, 150); gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow), 4); gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *) scrolledwindow, settings.shadow_type); textview = gtk_text_view_new(); gtk_widget_show(textview); gtk_container_add(GTK_CONTAINER(scrolledwindow), textview); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_WORD); gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE); gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)), about, -1); gtk_widget_set_sensitive(textview, FALSE); label = gtk_label_new(_("See TRANSLATION-HOWTO in Xiphos source")); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_set_size_request(label, -2, 24); href = gtk_link_button_new_with_label("http://xiphos.org/development/", _("Xiphos development")); gtk_widget_show(href); gtk_box_pack_start(GTK_BOX(vbox), href, FALSE, FALSE, 0); dialog_action_area = #ifdef HAVE_GTK_312 gtk_dialog_get_content_area(GTK_DIALOG(dialog_about_trans)); #else gtk_dialog_get_action_area(GTK_DIALOG(dialog_about_trans)); #endif g_object_set_data(G_OBJECT(dialog_about_trans), "dialog_action_area", dialog_action_area); gtk_widget_show(dialog_action_area); gtk_container_set_border_width(GTK_CONTAINER(dialog_action_area), 10); #ifdef USE_GTK_3 hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); #else hbuttonbox = gtk_hbutton_box_new(); #endif gtk_widget_show(hbuttonbox); gtk_box_pack_start(GTK_BOX(dialog_action_area), hbuttonbox, TRUE, TRUE, 0); gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox), GTK_BUTTONBOX_END); button = #ifdef HAVE_GTK_310 gtk_button_new_with_mnemonic(_("Close")); #else gtk_button_new_from_stock(GTK_STOCK_CLOSE); #endif gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(hbuttonbox), button); #ifdef HAVE_GTK_218 gtk_widget_set_can_default(button, TRUE); #elif defined(USE_GTK_3) gtk_widget_set_can_default(button, 1); #else GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); #endif g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(about_trans_ok), NULL); return dialog_about_trans; }
GaimGtkXferDialog * gaim_gtkxfer_dialog_new(void) { GaimGtkXferDialog *dialog; GtkWidget *window; GtkWidget *vbox1, *vbox2; GtkWidget *bbox; GtkWidget *sw; GtkWidget *sep; GtkWidget *button; GtkWidget *disclosure; GtkWidget *table; GtkWidget *checkbox; dialog = g_new0(GaimGtkXferDialog, 1); dialog->keep_open = gaim_prefs_get_bool("/gaim/gtk/filetransfer/keep_open"); dialog->auto_clear = gaim_prefs_get_bool("/gaim/gtk/filetransfer/clear_finished"); dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_role(GTK_WINDOW(window), "file transfer"); gtk_window_set_title(GTK_WINDOW(window), _("File Transfers")); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_container_set_border_width(GTK_CONTAINER(window), BOX_SPACING); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); /* Create the parent vbox for everything. */ vbox1 = gtk_vbox_new(FALSE, BOX_SPACING); gtk_container_add(GTK_CONTAINER(window), vbox1); gtk_widget_show(vbox1); /* Create the main vbox for top half of the window. */ vbox2 = gtk_vbox_new(FALSE, CONTAINER_BORDER_WIDTH); gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); gtk_widget_show(vbox2); /* Setup the listbox */ sw = setup_tree(dialog); gtk_box_pack_start(GTK_BOX(vbox2), sw, TRUE, TRUE, 0); gtk_widget_set_size_request(sw,-1, 140); /* "Keep the dialog open" */ checkbox = gtk_check_button_new_with_mnemonic( _("_Keep the dialog open")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), dialog->keep_open); g_signal_connect(G_OBJECT(checkbox), "toggled", G_CALLBACK(toggle_keep_open_cb), dialog); gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0); gtk_widget_show(checkbox); /* "Clear finished transfers" */ checkbox = gtk_check_button_new_with_mnemonic( _("_Clear finished transfers")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), dialog->auto_clear); g_signal_connect(G_OBJECT(checkbox), "toggled", G_CALLBACK(toggle_clear_finished_cb), dialog); gtk_box_pack_start(GTK_BOX(vbox2), checkbox, FALSE, FALSE, 0); gtk_widget_show(checkbox); /* "Download Details" arrow */ disclosure = gaim_disclosure_new(_("Show transfer details"), _("Hide transfer details")); dialog->disclosure = disclosure; gtk_box_pack_start(GTK_BOX(vbox2), disclosure, FALSE, FALSE, 0); gtk_widget_show(disclosure); gtk_widget_set_sensitive(disclosure, FALSE); #if 0 g_signal_connect(G_OBJECT(disclosure), "toggled", G_CALLBACK(toggle_details_cb), dialog); #endif /* Separator */ sep = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox2), sep, FALSE, FALSE, 0); gtk_widget_show(sep); /* The table of information. */ table = make_info_table(dialog); gtk_box_pack_start(GTK_BOX(vbox2), table, TRUE, TRUE, 0); /* Setup the disclosure for the table. */ gaim_disclosure_set_container(GAIM_DISCLOSURE(disclosure), table); /* Now the button box for the buttons */ bbox = gtk_hbutton_box_new(); gtk_box_set_spacing(GTK_BOX(bbox), CONTAINER_BORDER_WIDTH); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, TRUE, 0); gtk_widget_show(bbox); /* Open button */ button = gtk_button_new_from_stock(GTK_STOCK_OPEN); gtk_widget_set_sensitive(button, FALSE); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); dialog->open_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(open_button_cb), dialog); /* Pause button */ button = gtk_button_new_with_mnemonic(_("_Pause")); #ifndef GAIM_SMALL_SCREEN gtk_widget_set_sensitive(button, FALSE); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); #endif dialog->pause_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pause_button_cb), dialog); /* Resume button */ button = gtk_button_new_with_mnemonic(_("_Resume")); #ifndef GAIM_SMALL_SCREEN gtk_widget_set_sensitive(button, FALSE); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); #endif dialog->resume_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(resume_button_cb), dialog); /* Remove button */ button = gtk_button_new_from_stock(GTK_STOCK_REMOVE); #ifndef GAIM_SMALL_SCREEN gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_hide(button); #endif dialog->remove_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(remove_button_cb), dialog); /* Stop button */ button = gtk_button_new_from_stock(GTK_STOCK_STOP); #ifndef GAIM_SMALL_SCREEN gtk_widget_set_sensitive(button, FALSE); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); #endif dialog->stop_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(stop_button_cb), dialog); /* Close button */ button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); gtk_widget_show(button); dialog->close_button = button; g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(close_button_cb), dialog); return dialog; }
static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionData *cd, CollectInfo *info) { ViewWindow *vw; GtkAllocation req_size; GdkGeometry geometry; gint w, h; if (!fd && !list && (!cd || !info)) return NULL; vw = g_new0(ViewWindow, 1); vw->window = window_new(GTK_WINDOW_TOPLEVEL, "view", PIXBUF_INLINE_ICON_VIEW, NULL, NULL); geometry.min_width = DEFAULT_MINIMAL_WINDOW_SIZE; geometry.min_height = DEFAULT_MINIMAL_WINDOW_SIZE; gtk_window_set_geometry_hints(GTK_WINDOW(vw->window), NULL, &geometry, GDK_HINT_MIN_SIZE); gtk_window_set_resizable(GTK_WINDOW(vw->window), TRUE); gtk_container_set_border_width(GTK_CONTAINER(vw->window), 0); vw->imd = image_new(FALSE); image_color_profile_set(vw->imd, options->color_profile.input_type, options->color_profile.use_image); image_color_profile_set_use(vw->imd, options->color_profile.enabled); image_background_set_color_from_options(vw->imd, FALSE); image_attach_window(vw->imd, vw->window, NULL, GQ_APPNAME, TRUE); image_auto_refresh_enable(vw->imd, TRUE); image_top_window_set_sync(vw->imd, TRUE); gtk_container_add(GTK_CONTAINER(vw->window), vw->imd->widget); gtk_widget_show(vw->imd->widget); view_window_dnd_init(vw); view_image_set_buttons(vw, vw->imd); g_signal_connect(G_OBJECT(vw->window), "destroy", G_CALLBACK(view_window_destroy_cb), vw); g_signal_connect(G_OBJECT(vw->window), "delete_event", G_CALLBACK(view_window_delete_cb), vw); g_signal_connect(G_OBJECT(vw->window), "key_press_event", G_CALLBACK(view_window_key_press_cb), vw); if (cd && info) { image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL)); if (options->image.enable_read_ahead) { CollectInfo * r_info = collection_next_by_info(cd, info); if (!r_info) r_info = collection_prev_by_info(cd, info); if (r_info) image_prebuffer_set(vw->imd, r_info->fd); } } else if (list) { view_window_set_list(vw, list); vw->list_pointer = vw->list; image_change_fd(vw->imd, (FileData *)vw->list->data, image_zoom_get_default(NULL)); if (options->image.enable_read_ahead) { GList *work = vw->list->next; if (work) image_prebuffer_set(vw->imd, (FileData *)work->data); } } else { image_change_fd(vw->imd, fd, image_zoom_get_default(NULL)); } /* Wait until image is loaded otherwise size is not defined */ int count; for (count = 10; count && !w && !h; count++) { image_get_image_size(vw->imd, &w, &h); usleep(100000); } if (image_zoom_get(vw->imd) == 0.0) { image_get_image_size(vw->imd, &w, &h); } else { pixbuf_renderer_get_scaled_size(PIXBUF_RENDERER(vw->imd->pr), &w, &h); } if (options->image.limit_window_size) { gint mw = gdk_screen_width() * options->image.max_window_size / 100; gint mh = gdk_screen_height() * options->image.max_window_size / 100; if (w > mw) w = mw; if (h > mh) h = mh; } gtk_window_set_default_size(GTK_WINDOW(vw->window), w, h); req_size.x = req_size.y = 0; req_size.width = w; req_size.height = h; gtk_widget_size_allocate(GTK_WIDGET(vw->window), &req_size); gtk_widget_set_size_request(vw->imd->pr, w, h); gtk_widget_show(vw->window); view_window_list = g_list_append(view_window_list, vw); file_data_register_notify_func(view_window_notify_cb, vw, NOTIFY_PRIORITY_LOW); return vw; }
static Tacwin * acwin_create(BluefishTextView * btv) { /*GtkCellRenderer *cell;*/ GtkWidget *hbox; /* GtkWidget *vbar; */ Tacwin *acw; GtkTreeSelection *selection; acw = g_slice_new0(Tacwin); acw->btv = btv; acw->in_fill = TRUE; acw->win = gtk_window_new(GTK_WINDOW_POPUP); /* We do not do any customized drawing in autocomplete window, as far as I can see, so probably we do not need to switch this on. * On MacOSX this causes the labels of acw->reflabel to pile up on each other, see report by Keith Gunthardt on Facebook: * https://www.facebook.com/photo.php?fbid=10152794950839751&set=p.10152794950839751&type=1 I (Olivier) think you are right Andrius, we can remove this call for all platforms, uncommenting it: gtk_widget_set_app_paintable(acw->win, TRUE); */ gtk_window_set_resizable(GTK_WINDOW(acw->win), FALSE); gtk_container_set_border_width(GTK_CONTAINER(acw->win), 1); gtk_window_set_decorated(GTK_WINDOW(acw->win), FALSE); gtk_window_set_type_hint(GTK_WINDOW(acw->win), GDK_WINDOW_TYPE_HINT_POPUP_MENU); acw->store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); acw->tree = GTK_TREE_VIEW(gtk_tree_view_new_with_model(GTK_TREE_MODEL(acw->store))); g_object_unref(acw->store); gtk_tree_view_set_headers_visible(acw->tree, FALSE); acw->scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(acw->scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); acw->cell = gtk_cell_renderer_text_new(); acw->column = gtk_tree_view_column_new_with_attributes("", acw->cell, "markup", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(acw->tree), acw->column); gtk_tree_view_set_enable_search(GTK_TREE_VIEW(acw->tree), FALSE); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(acw->tree)); g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(acw_selection_changed_lcb), acw); /* gtk_tree_view_set_search_column(GTK_TREE_VIEW(acw->tree),1); gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(acw->tree),acwin_tree_search_lcb,prefix,NULL);*/ /*g_signal_connect_swapped(GTK_WINDOW(acw->win),"expose-event",G_CALLBACK(ac_paint),acw->win); */ /*gtk_window_set_position (GTK_WINDOW(acw->win), GTK_WIN_POS_MOUSE); */ gtk_container_add(GTK_CONTAINER(acw->scroll), GTK_WIDGET(acw->tree)); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), acw->scroll, FALSE, TRUE, 0); acw->reflabel = gtk_label_new(NULL); gtk_label_set_line_wrap(GTK_LABEL(acw->reflabel), TRUE); gtk_misc_set_alignment(GTK_MISC(acw->reflabel), 0.1, 0.1); gtk_box_pack_start(GTK_BOX(hbox), acw->reflabel, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(acw->win), hbox); /*gtk_widget_set_size_request(acw->reflabel,150,-1); */ gtk_widget_show_all(acw->scroll); gtk_widget_show(hbox); /*gtk_widget_set_size_request(GTK_WIDGET(acw->tree),100,200); */ /*gtk_widget_set_size_request(acw->win, 150, 200); */ /*g_signal_connect(G_OBJECT(acw->win),"key-release-event",G_CALLBACK(acwin_key_release_lcb),acw); */ return acw; }
static void gtk_tooltip_init (GtkTooltip *tooltip) { GtkStyleContext *context; GtkWidget *window; GtkWidget *box; GtkWidget *image; GtkWidget *label; GdkScreen *screen; GdkVisual *visual; tooltip->timeout_id = 0; tooltip->browse_mode_timeout_id = 0; tooltip->browse_mode_enabled = FALSE; tooltip->keyboard_mode_enabled = FALSE; tooltip->current_window = NULL; tooltip->keyboard_widget = NULL; tooltip->tooltip_widget = NULL; tooltip->toplevel_window = NULL; tooltip->last_window = NULL; window = gtk_window_new (GTK_WINDOW_POPUP); screen = gtk_widget_get_screen (window); visual = gdk_screen_get_rgba_visual (screen); if (visual != NULL) gtk_widget_set_visual (window, visual); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_widget_set_app_paintable (window, TRUE); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_widget_set_name (window, "gtk-tooltip"); g_signal_connect (window, "hide", G_CALLBACK (gtk_tooltip_window_hide), tooltip); context = gtk_widget_get_style_context (window); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLTIP); g_signal_connect_swapped (window, "draw", G_CALLBACK (gtk_tooltip_paint_window), tooltip); g_signal_connect_swapped (window, "realize", G_CALLBACK (gtk_tooltip_realize_window), tooltip); g_signal_connect_swapped (window, "composited-changed", G_CALLBACK (gtk_tooltip_composited_changed), tooltip); /* FIXME: don't hardcode the padding */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_widget_set_margin_left (box, 6); gtk_widget_set_margin_right (box, 6); gtk_widget_set_margin_top (box, 6); gtk_widget_set_margin_bottom (box, 6); gtk_container_add (GTK_CONTAINER (window), box); gtk_widget_show (box); image = gtk_image_new (); gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0); label = gtk_label_new (""); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0); tooltip->window = window; tooltip->box = box; tooltip->image = image; tooltip->label = label; tooltip->custom_widget = NULL; }
/* * 画主界面 */ GtkWidget *CreateMainWindow() { // 控件初始化 mainWindow.layout = gtk_layout_new(NULL, NULL); mainWindow.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); mainWindow.list_puppet = gtk_tree_view_new(); mainWindow.entry_target = gtk_entry_new(); mainWindow.label_puppet = gtk_label_new("代理端主机列表:"); mainWindow.label_method = gtk_label_new("攻击方式:"); mainWindow.label_target = gtk_label_new("目标主机地址:"); mainWindow.button_attack = gtk_button_new_with_label("攻击"); mainWindow.button_stop = gtk_button_new_with_label("停止"); mainWindow.button_quit = gtk_button_new_with_label("退出"); mainWindow.button_insert = gtk_button_new_with_label("新增"); mainWindow.button_delete = gtk_button_new_with_label("删除"); mainWindow.checkbutton_icmp = gtk_check_button_new_with_label("ICMP Flood"); mainWindow.checkbutton_tcp = gtk_check_button_new_with_label("TCP Flood"); mainWindow.checkbutton_udp = gtk_check_button_new_with_label("UDP Flood"); mainWindow.selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(mainWindow.list_puppet)); // 设置控件大小 gtk_widget_set_size_request(mainWindow.list_puppet, 200, 150); gtk_widget_set_size_request(mainWindow.entry_target, 200, 30); gtk_widget_set_size_request(mainWindow.label_puppet, 100, 30); gtk_widget_set_size_request(mainWindow.label_target, 100, 30); gtk_widget_set_size_request(mainWindow.label_method, 60, 30); gtk_widget_set_size_request(mainWindow.button_attack, 80, 40); gtk_widget_set_size_request(mainWindow.button_stop, 80, 40); gtk_widget_set_size_request(mainWindow.button_quit, 80, 40); gtk_widget_set_size_request(mainWindow.button_insert, 80, 40); gtk_widget_set_size_request(mainWindow.button_delete, 80, 40); gtk_widget_set_size_request(mainWindow.checkbutton_icmp, 120, 20); gtk_widget_set_size_request(mainWindow.checkbutton_tcp, 100, 20); gtk_widget_set_size_request(mainWindow.checkbutton_udp, 100, 20); //将控件添加到界面 gtk_container_add((GtkContainer *) mainWindow.window, mainWindow.layout); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.list_puppet, 20, 50); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.entry_target, 130, 280); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.label_puppet, 20, 20); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.label_method, 20, 220); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.label_target, 20, 280); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.button_attack, 20, 330); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.button_stop, 140, 330); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.button_quit, 260, 330); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.button_insert, 240, 50); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.button_delete, 240, 160); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.checkbutton_icmp, 20, 245); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.checkbutton_tcp, 140, 245); gtk_layout_put((GtkLayout *) mainWindow.layout, mainWindow.checkbutton_udp, 260, 245); init_list(mainWindow.list_puppet); // 设置主窗口标题 gtk_window_set_title(GTK_WINDOW(mainWindow.window), "TFN2k 测试版"); // 设置主窗口大小 gtk_widget_set_usize(GTK_WIDGET(mainWindow.window), 360, 390); // 设置主窗口位置 gtk_window_set_position(GTK_WINDOW(mainWindow.window), GTK_WIN_POS_CENTER_ALWAYS); // 设置窗口图标 gtk_window_set_icon(GTK_WINDOW(mainWindow.window), create_pixbuf("images/web.png")); // 设置窗口大小不可更改 gtk_window_set_resizable(GTK_WINDOW(mainWindow.window), FALSE); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mainWindow.list_puppet), FALSE); // 点击quit键,回调gtk_main_quit函数 g_signal_connect(mainWindow.window, "destroy", G_CALLBACK(gtk_main_quit), NULL); // 点击退出键,回调gtk_main_quit函数 g_signal_connect(mainWindow.button_quit, "clicked", G_CALLBACK(gtk_main_quit), NULL); // 点击攻击键,回调tfn_main_attack函数 g_signal_connect(mainWindow.button_attack, "clicked", G_CALLBACK(tfn_main_attack), NULL); // 点击停止键,回调tfn_main_stop函数 g_signal_connect(mainWindow.button_stop, "clicked", G_CALLBACK(tfn_main_stop), NULL); // 点击新增键,回调tfn_main_insert函数 g_signal_connect(mainWindow.button_insert, "clicked", G_CALLBACK(tfn_main_insert), NULL); // 点击删除键,回调tfn_main_delete函数 g_signal_connect(mainWindow.button_delete, "clicked", G_CALLBACK(tfn_main_delete), mainWindow.selection); return mainWindow.window; }
void ssl_manager_create(void) { GtkWidget *window; GtkWidget *scroll; GtkWidget *hbox1; GtkWidget *vbox1; GtkWidget *certlist; GtkWidget *view_btn; GtkWidget *delete_btn; GtkWidget *close_btn; window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "ssl_manager"); gtk_window_set_title (GTK_WINDOW(window), _("Saved SSL certificates")); gtk_container_set_border_width (GTK_CONTAINER (window), 8); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW (window), TRUE); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(ssl_manager_close_cb), NULL); g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(key_pressed), NULL); MANAGE_WINDOW_SIGNALS_CONNECT (window); hbox1 = gtk_hbox_new(FALSE, 6); vbox1 = gtk_vbox_new(FALSE, 0); delete_btn = gtk_button_new_from_stock(GTK_STOCK_DELETE); g_signal_connect(G_OBJECT(delete_btn), "clicked", G_CALLBACK(ssl_manager_delete_cb), NULL); view_btn = gtk_button_new_from_stock(GTK_STOCK_PROPERTIES); g_signal_connect(G_OBJECT(view_btn), "clicked", G_CALLBACK(ssl_manager_view_cb), NULL); close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE); g_signal_connect(G_OBJECT(close_btn), "clicked", G_CALLBACK(ssl_manager_close_cb), NULL); certlist = ssl_manager_list_view_create(); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER (scroll), certlist); gtk_box_pack_start(GTK_BOX(hbox1), scroll, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox1), vbox1, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox1), view_btn, FALSE, FALSE, 4); gtk_box_pack_start(GTK_BOX(vbox1), delete_btn, FALSE, FALSE, 4); gtk_box_pack_end(GTK_BOX(vbox1), close_btn, FALSE, FALSE, 4); gtk_widget_show(certlist); gtk_widget_show(scroll); gtk_widget_show(hbox1); gtk_widget_show(vbox1); gtk_widget_show(close_btn); gtk_widget_show(delete_btn); gtk_widget_show(view_btn); gtk_container_add(GTK_CONTAINER (window), hbox1); manager.window = window; manager.hbox1 = hbox1; manager.vbox1 = vbox1; manager.certlist = certlist; manager.view_btn = view_btn; manager.delete_btn = delete_btn; manager.close_btn = close_btn; gtk_widget_show(window); }
int main (int argc, char *argv[]) { #if GST_GL_HAVE_WINDOW_X11 XInitThreads (); #endif gst_init (&argc, &argv); gtk_init (&argc, &argv); GstElement* pipeline = gst_pipeline_new ("pipeline"); //window that contains an area where the video is drawn GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_window_move (GTK_WINDOW (window), 300, 10); gtk_window_set_title (GTK_WINDOW (window), "gtkgstwidget"); //window to control the states GtkWidget* window_control = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (window_control), FALSE); gtk_window_move (GTK_WINDOW (window_control), 10, 10); GtkWidget* grid = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window_control), grid); //control state null GtkWidget* button_state_null = gtk_button_new_with_label ("GST_STATE_NULL"); g_signal_connect (G_OBJECT (button_state_null), "clicked", G_CALLBACK (button_state_null_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_null, 0, 1, 1, 1); gtk_widget_show (button_state_null); //control state ready GtkWidget* button_state_ready = gtk_button_new_with_label ("GST_STATE_READY"); g_signal_connect (G_OBJECT (button_state_ready), "clicked", G_CALLBACK (button_state_ready_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_ready, 0, 2, 1, 1); gtk_widget_show (button_state_ready); //control state paused GtkWidget* button_state_paused = gtk_button_new_with_label ("GST_STATE_PAUSED"); g_signal_connect (G_OBJECT (button_state_paused), "clicked", G_CALLBACK (button_state_paused_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_paused, 0, 3, 1, 1); gtk_widget_show (button_state_paused); //control state playing GtkWidget* button_state_playing = gtk_button_new_with_label ("GST_STATE_PLAYING"); g_signal_connect (G_OBJECT (button_state_playing), "clicked", G_CALLBACK (button_state_playing_cb), pipeline); gtk_grid_attach (GTK_GRID (grid), button_state_playing, 0, 4, 1, 1); gtk_widget_show (button_state_playing); gtk_widget_show (grid); gtk_widget_show (window_control); //area where the video is drawn g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(destroy_cb), pipeline); //configure the pipeline GstElement* videosrc = gst_element_factory_make ("videotestsrc", "videotestsrc"); GstElement* effect = gst_element_factory_make ("glfiltercube", "cube"); GstElement* videosink = gst_element_factory_make ("gtkglsink", "gtkglsink"); GtkWidget *area; g_object_get (videosink, "widget", &area, NULL); gtk_container_add (GTK_CONTAINER (window), area); gtk_widget_realize(area); GstCaps *caps = gst_caps_new_simple("video/x-raw", "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480, "format", G_TYPE_STRING, "BGRA", NULL); gst_bin_add_many (GST_BIN (pipeline), videosrc, effect, videosink, NULL); gboolean link_ok = gst_element_link (effect, videosink) ; if(!link_ok) { g_warning("Failed to link glfiltercube to gtkglsink!\n") ; return -1; } if (!gst_element_link_filtered (videosrc, effect, caps)) { g_warning("Failed to link viideotestsrc to glfiltercube!\n") ; return -1; } gst_caps_unref (caps); //set window id on this event GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); g_signal_connect(bus, "message::error", G_CALLBACK(end_stream_cb), pipeline); g_signal_connect(bus, "message::warning", G_CALLBACK(end_stream_cb), pipeline); g_signal_connect(bus, "message::eos", G_CALLBACK(end_stream_cb), pipeline); gst_object_unref (bus); //start GstStateChangeReturn ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { g_print ("Failed to start up pipeline!\n"); return -1; } gtk_widget_show_all (window); gtk_main(); gst_deinit (); return 0; }
static void gtk_get_credentials(struct cli_credentials *credentials) { const char *ret; GtkWidget *dialog; GtkWidget *label; GtkWidget *table; GtkWidget *entry_username; GtkWidget *entry_password; GtkWidget *dialog_action_area1; GtkWidget *cancelbutton1; GtkWidget *okbutton1; GtkWidget *anonymous; 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); 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_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); okbutton1 = gtk_button_new_from_stock ("gtk-ok"); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), okbutton1, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); 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); 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); } break; default: ret = NULL; break; } gtk_widget_destroy (dialog); }
static void enroll_fingerprints (GtkWindow *parent, GtkWidget *label1, GtkWidget *label2, ActUser *user) { GDBusProxy *device; GtkBuilder *dialog; EnrollData *data; GtkWidget *ass; char *msg; GVariant *result; GError *error = NULL; device = NULL; if (manager == NULL) { create_manager (); if (manager != NULL) device = get_first_device (); } else { device = get_first_device (); } if (manager == NULL || device == NULL) { GtkWidget *d; d = get_error_dialog (_("Could not access any fingerprint readers"), _("Please contact your system administrator for help."), parent); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); return; } data = g_new0 (EnrollData, 1); data->device = device; data->label1 = label1; data->label2 = label2; /* Get some details about the device */ result = g_dbus_connection_call_sync (connection, "net.reactivated.Fprint", g_dbus_proxy_get_object_path (data->device), "org.freedesktop.DBus.Properties", "GetAll", g_variant_new ("(s)", "net.reactivated.Fprint.Device"), G_VARIANT_TYPE ("(a{sv})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); if (result) { GVariant *props; gchar *scan_type; g_variant_get (result, "(@a{sv})", &props); g_variant_lookup (props, "name", "s", &data->name); g_variant_lookup (props, "scan-type", "s", &scan_type); if (g_strcmp0 (scan_type, "swipe") == 0) data->is_swipe = TRUE; g_free (scan_type); g_variant_unref (props); g_variant_unref (result); } dialog = gtk_builder_new (); if (!gtk_builder_add_from_resource (dialog, "/org/gnome/control-center/user-accounts/account-fingerprint.ui", &error)) { g_error ("%s", error->message); g_error_free (error); return; } data->dialog = dialog; ass = WID ("assistant"); gtk_window_set_title (GTK_WINDOW (ass), _("Enable Fingerprint Login")); gtk_window_set_transient_for (GTK_WINDOW (ass), parent); gtk_window_set_modal (GTK_WINDOW (ass), TRUE); gtk_window_set_resizable (GTK_WINDOW (ass), FALSE); gtk_window_set_type_hint (GTK_WINDOW (ass), GDK_WINDOW_TYPE_HINT_DIALOG); g_signal_connect (G_OBJECT (ass), "cancel", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "close", G_CALLBACK (assistant_cancelled), data); g_signal_connect (G_OBJECT (ass), "prepare", G_CALLBACK (assistant_prepare), data); /* Page 1 */ gtk_combo_box_set_active (GTK_COMBO_BOX (WID ("finger_combobox")), 0); g_signal_connect (G_OBJECT (WID ("radiobutton1")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton2")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("radiobutton3")), "toggled", G_CALLBACK (finger_radio_button_toggled), data); g_signal_connect (G_OBJECT (WID ("finger_combobox")), "changed", G_CALLBACK (finger_combobox_changed), data); data->finger = selected_finger (dialog); g_object_set_data (G_OBJECT (WID("page1")), "name", "intro"); /* translators: * The variable is the name of the device, for example: * "To enable fingerprint login, you need to save one of your fingerprints, using the * 'Digital Persona U.are.U 4000/4000B' device." */ msg = g_strdup_printf (_("To enable fingerprint login, you need to save one of your fingerprints, using the '%s' device."), data->name); gtk_label_set_text (GTK_LABEL (WID("intro-label")), msg); g_free (msg); gtk_assistant_set_page_complete (GTK_ASSISTANT (ass), WID("page1"), TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page1"), _("Selecting finger")); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page2"), _("Enrolling fingerprints")); gtk_assistant_set_page_title (GTK_ASSISTANT (ass), WID("page3"), _("Summary")); /* Page 2 */ g_object_set_data (G_OBJECT (WID("page2")), "name", "enroll"); msg = g_strdup_printf (TR(finger_str_to_msg (data->finger, data->is_swipe)), data->name); gtk_label_set_text (GTK_LABEL (WID("enroll-label")), msg); g_free (msg); /* Page 3 */ g_object_set_data (G_OBJECT (WID("page3")), "name", "summary"); data->ass = ass; gtk_widget_show_all (ass); }
/* Show the CRC checking window */ void gzrt_wcrc_show ( MAINWIN * c ) { GtkWidget * window; GtkWidget * vbox; GtkWidget * hbox; GtkWidget * table; GtkWidget * label; GtkWidget * image; GtkWidget * entry; GtkWidget * button; /* Does this parent window exist? */ if( g_list_find( parents, c ) ) /* Yeah */ return; /* Add the parent */ parents = g_list_append( parents, c ); /* Calculate CRCs */ n64rom_crc( c->c, crcs ); /* Read in old CRCs */ oldcrc[0] = c->c->head.CRC1; oldcrc[1] = c->c->head.CRC2; /* Set up the window */ window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); gtk_window_set_title( GTK_WINDOW(window), "CRC Checker" ); gtk_window_set_position( GTK_WINDOW(window), GTK_WIN_POS_CENTER ); gtk_window_set_modal( GTK_WINDOW(window), TRUE ); gtk_window_set_resizable( GTK_WINDOW(window), FALSE ); gtk_container_set_border_width( GTK_CONTAINER(window), 12 ); /* Create vbox */ vbox = gtk_vbox_new( FALSE, 8 ); /* Create table */ table = gtk_table_new( 2, 2, FALSE ); gtk_table_set_row_spacings( GTK_TABLE(table), 8 ); gtk_table_set_col_spacings( GTK_TABLE(table), 8 ); /* Create the two CRC rows */ for( int i = 0; i < 2; i++ ) { char buffer[64]; /* Generate text */ sprintf( buffer, "CRC %u:", i + 1 ); /* Create label */ label = gtk_label_new( buffer ); /* Create hbox */ hbox = gtk_hbox_new( FALSE, 4 ); /* Create text entry */ entry = gtk_entry_new(); sprintf( buffer, "0x%08X", crcs[i] ); gtk_entry_set_text( GTK_ENTRY(entry), buffer ); /* Create image */ image = gtk_image_new_from_stock( (crcs[i]==oldcrc[i] ? "gtk-yes" : "gtk-no"), GTK_ICON_SIZE_SMALL_TOOLBAR ); /* Hookup entries */ sprintf( buffer, "crc-%u", i + 1 ); HOOKUP( window, entry, buffer ); sprintf( buffer, "crc-%u-img", i + 1 ); HOOKUP( window, image, buffer ); /* Pack */ gtk_table_attach( GTK_TABLE(table), label, 0, 1, i, i + 1, GTK_FILL, 0, 0, 0 ); gtk_table_attach( GTK_TABLE(table), hbox, 1, 2, i, i + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0 ); gtk_box_pack_start( GTK_BOX(hbox), entry, TRUE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(hbox), image, FALSE, TRUE, 0 ); } /* Create button hbox */ hbox = gtk_hbox_new( TRUE, 12 ); /* Create buttons */ button = gtk_button_new_with_label( "Fix" ); g_signal_connect_swapped( G_OBJECT(button), "clicked", G_CALLBACK(write_crcs), window ); gtk_widget_set_sensitive( button, (!memcmp(crcs,oldcrc,8) ? FALSE : TRUE) ); gtk_box_pack_start( GTK_BOX(hbox), button, TRUE, TRUE, 12 ); button = gtk_button_new_with_label( "Close" ); g_signal_connect_swapped( G_OBJECT(button), "clicked", G_CALLBACK(gzrt_wcrc_close), window ); gtk_box_pack_start( GTK_BOX(hbox), button, TRUE, TRUE, 12 ); /* Pack everything */ gtk_box_pack_start( GTK_BOX(vbox), table, TRUE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(vbox), hbox, TRUE, FALSE, 0 ); gtk_container_add( GTK_CONTAINER(window), vbox ); /* Signals */ g_signal_connect_swapped( G_OBJECT(window), "destroy", G_CALLBACK(gzrt_wcrc_closed), c ); /* Hookup data */ HOOKUP( window, c->c, "rom-context" ); /* Show */ gtk_widget_show_all( window ); }
/* * Trash entry * Signal handler for "activate" trash entry */ gboolean trash_entry() { FILE *fp = NULL; GtkWidget *msg_dialog = NULL; gchar entry_display_name[MAX_NAME_LEN]; gchar curr_entry_path[MAX_PATH_LEN]; gchar trash_entry_path[MAX_PATH_LEN]; GList *entry_item = NULL; book_data *book = NULL; section_data *section = NULL; section_data *trash_section = NULL; entry_data *entry = NULL; gint result; // Assert master exists g_assert_nonnull(master); // Get currently selected book = get_current_book_or_return_with_warning(); section = get_current_section_or_return_with_warning(); entry = get_current_entry_or_return_with_warning(); // Get trash section trash_section = book->trash_section; // Curr entry file path g_snprintf(curr_entry_path, sizeof(curr_entry_path), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, section->name, G_DIR_SEPARATOR_S, entry->name); // Trash entry file path g_snprintf(trash_entry_path, sizeof(trash_entry_path), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, trash_section_name, G_DIR_SEPARATOR_S, entry->name); // Set display name strncpy(entry_display_name, entry->name, MAX_NAME_LEN-5); if(strlen(entry_display_name) > 25) strcpy(entry_display_name+25, "...\0"); // Check that new entry path is valid fp = fopen(trash_entry_path, "wx"); if (fp == NULL) { sn_warning("Unable to trash entry [%s].", trash_entry_path); msg_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to trash entry \"%s\".", entry_display_name); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), "Please ensure the entry name doesn't aleady exist."); gtk_window_set_type_hint(GTK_WINDOW(msg_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(msg_dialog), FALSE); gtk_window_set_title(GTK_WINDOW(msg_dialog), app_name); result = gtk_dialog_run(GTK_DIALOG(msg_dialog)); gtk_widget_destroy(msg_dialog); return FALSE; } fclose(fp); // Remove file created by previous open result = remove(trash_entry_path); sn_trace("Trashing entry [%s] to [%s].", curr_entry_path, trash_entry_path); // Move the entry file to the new path result = rename(curr_entry_path, trash_entry_path); if(result == 0) { // Remove history remove_history(); // Select next entry entry_item = g_list_find(section->entry_list, entry); entry_item = entry_item->next; if(entry_item != NULL) section->curr_entry = entry_item->data; else section->curr_entry = NULL; // Remove entry section->entry_list = g_list_remove(section->entry_list, entry); // Append entry trash_section->entry_list = g_list_append(trash_section->entry_list, entry); // Update entry entry->parent_section = trash_section; // Write book write_book(book, note_dir); // Update view populate_entries(book, section); return TRUE; } else { sn_warning("Unable to trash entry [%s].", curr_entry_path); return FALSE; } return FALSE; } // Trash entry
GtkWidget * gimp_container_popup_new (GimpContainer *container, GimpContext *context, GimpViewType view_type, gint default_view_size, gint view_size, gint view_border_width, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const gchar *dialog_stock_id, const gchar *dialog_tooltip) { GimpContainerPopup *popup; g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (default_view_size > 0 && default_view_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL); g_return_val_if_fail (view_size > 0 && view_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL); g_return_val_if_fail (view_border_width >= 0 && view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH, NULL); g_return_val_if_fail (dialog_factory == NULL || GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL); if (dialog_factory) { g_return_val_if_fail (dialog_identifier != NULL, NULL); g_return_val_if_fail (dialog_stock_id != NULL, NULL); g_return_val_if_fail (dialog_tooltip != NULL, NULL); } popup = g_object_new (GIMP_TYPE_CONTAINER_POPUP, "type", GTK_WINDOW_POPUP, NULL); gtk_window_set_resizable (GTK_WINDOW (popup), FALSE); popup->container = container; popup->orig_context = context; popup->context = gimp_context_new (context->gimp, "popup", context); popup->view_type = view_type; popup->default_view_size = default_view_size; popup->view_size = view_size; popup->view_border_width = view_border_width; g_signal_connect (popup->context, gimp_context_type_to_signal_name (gimp_container_get_children_type (container)), G_CALLBACK (gimp_container_popup_context_changed), popup); if (dialog_factory) { popup->dialog_factory = dialog_factory; popup->dialog_identifier = g_strdup (dialog_identifier); popup->dialog_stock_id = g_strdup (dialog_stock_id); popup->dialog_tooltip = g_strdup (dialog_tooltip); } gimp_container_popup_create_view (popup); return GTK_WIDGET (popup); }
/* * Rename entry * Signal handler for "activate" rename entry */ gboolean rename_entry() { FILE *fp = NULL; GtkWidget *name_dialog = NULL; GtkWidget *msg_dialog = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *label = NULL; GtkWidget *name_entry = NULL; const gchar *entry_text = NULL; gchar old_entry_display_name[MAX_NAME_LEN]; gchar new_entry_display_name[MAX_NAME_LEN]; gchar new_entry_name[MAX_PATH_LEN]; gchar old_entry_name[MAX_PATH_LEN]; book_data *book = NULL; section_data *section = NULL; entry_data *entry = NULL; gchar *temp_string; gint result; // Assert master exists g_assert_nonnull(master); // Get currently selected book = get_current_book_or_return_with_warning(); section = get_current_section_or_return_with_warning(); entry = get_current_entry_or_return_with_warning(); // Write current entry write_current_entry(); // Create name dialog name_dialog = gtk_dialog_new_with_buttons(app_name, GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_widget_set_size_request(name_dialog, SM_DLG_WIDTH, SM_DLG_HEIGHT); gtk_window_set_type_hint(GTK_WINDOW(name_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(name_dialog), FALSE); label = gtk_label_new("Enter new entry name..."); name_entry = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(name_entry), MAX_NAME_LEN-5); // Get auto name if(options.auto_name_entry == TRUE) { temp_string = g_malloc0(MAX_NAME_LEN); strdelchr(temp_string, get_auto_entry_name(get_text_view(book)), ILLEGAL_CHARS); temp_string[MAX_NAME_LEN-5] = 0; if(strcmp(temp_string, "") == 0) gtk_entry_set_text(GTK_ENTRY(name_entry), entry->name); else gtk_entry_set_text(GTK_ENTRY(name_entry), temp_string); g_free(temp_string); } else { gtk_entry_set_text(GTK_ENTRY(name_entry), entry->name); } vbox = gtk_dialog_get_content_area(GTK_DIALOG(name_dialog)); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), name_entry, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); gtk_entry_set_activates_default(GTK_ENTRY(name_entry), TRUE); gtk_dialog_set_default_response (GTK_DIALOG(name_dialog),GTK_RESPONSE_ACCEPT); gtk_widget_show_all(name_dialog); // Run dialog result = gtk_dialog_run(GTK_DIALOG(name_dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: entry_text = gtk_entry_get_text(GTK_ENTRY(name_entry)); // Scan name for illegal characters temp_string = g_malloc0(MAX_NAME_LEN); strdelchr(temp_string, entry_text, ILLEGAL_CHARS); gtk_entry_set_text(GTK_ENTRY(name_entry), temp_string); g_free(temp_string); entry_text = gtk_entry_get_text(GTK_ENTRY(name_entry)); // Old entry file g_snprintf(old_entry_name, sizeof(old_entry_name), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, section->name, G_DIR_SEPARATOR_S, entry->name); // New entry file g_snprintf(new_entry_name, sizeof(new_entry_name), "%s%s%s%s%s%s%s.txt", note_dir, G_DIR_SEPARATOR_S, book->name, G_DIR_SEPARATOR_S, section->name, G_DIR_SEPARATOR_S, entry_text); // Ignore rename if names match if(strcmp(entry->name, entry_text) == 0) { gtk_widget_destroy(name_dialog); return TRUE; } // Set display name strncpy(old_entry_display_name, entry->name, MAX_NAME_LEN-5); if(strlen(old_entry_display_name) > 25) strcpy(old_entry_display_name+25, "...\0"); strncpy(new_entry_display_name, entry_text, MAX_NAME_LEN-5); if(strlen(new_entry_display_name) > 25) strcpy(new_entry_display_name+25, "...\0"); // Check that new entry name is valid if(strlen(entry_text) < 1) { sn_warning("Unable to rename entry [%s] to [%s].", entry->name, entry_text); msg_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to rename entry \"%s\" to \"%s\".", old_entry_display_name, new_entry_display_name); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), "Please ensure the entry name contains a valid character."); gtk_window_set_title(GTK_WINDOW(msg_dialog), app_name); gtk_window_set_type_hint(GTK_WINDOW(msg_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(msg_dialog), FALSE); result = gtk_dialog_run(GTK_DIALOG(msg_dialog)); gtk_widget_destroy(name_dialog); gtk_widget_destroy(msg_dialog); return FALSE; } // Check that new entry name is valid fp = fopen(new_entry_name, "wx"); if (fp == NULL) { sn_warning("Unable to rename entry [%s] to [%s].", entry->name, entry_text); msg_dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Unable to rename entry \"%s\" to \"%s\".", old_entry_display_name, new_entry_display_name); gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog), "Please ensure the entry name doesn't aleady exist."); gtk_window_set_title(GTK_WINDOW(msg_dialog), app_name); gtk_window_set_type_hint(GTK_WINDOW(msg_dialog), GDK_WINDOW_TYPE_HINT_MENU); gtk_window_set_resizable(GTK_WINDOW(msg_dialog), FALSE); result = gtk_dialog_run(GTK_DIALOG(msg_dialog)); gtk_widget_destroy(name_dialog); gtk_widget_destroy(msg_dialog); return FALSE; } fclose(fp); sn_trace("Renaming entry [%s] to [%s].", entry->name, entry_text); // Rename entry file result = rename(old_entry_name, new_entry_name); if(result == 0) { // Remove history remove_history(); // Update entry strcpy(entry->name, entry_text); // Update book write_book(book, note_dir); // Update view populate_entries(book, section); on_entry_change(get_entry_view(book), book); gtk_widget_destroy(name_dialog); return TRUE; } else { sn_warning("Unable to rename entry [%s].", entry->name); gtk_widget_destroy(name_dialog); return FALSE; } default: gtk_widget_destroy(name_dialog); return FALSE; } // End switch return FALSE; } // Rename entry
static void gtr_preferences_dialog_init (GtrPreferencesDialog * dlg) { GtrPreferencesDialogPrivate *priv; GtkWidget *action_area; GtkWidget *profiles_toolbar; GtkWidget *profiles_scrolled_window; GtkBuilder *builder; GtkBox *content_area; GtkStyleContext *context; gchar *root_objects[] = { "notebook", "adjustment1", "adjustment2", "adjustment3", "model1", NULL }; dlg->priv = GTR_PREFERENCES_DIALOG_GET_PRIVATE (dlg); priv = dlg->priv; priv->ui_settings = g_settings_new ("org.gnome.gtranslator.preferences.ui"); priv->editor_settings = g_settings_new ("org.gnome.gtranslator.preferences.editor"); priv->files_settings = g_settings_new ("org.gnome.gtranslator.preferences.files"); gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL); gtk_window_set_title (GTK_WINDOW (dlg), _("Gtranslator Preferences")); gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE); gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE); action_area = gtk_dialog_get_action_area (GTK_DIALOG (dlg)); content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))); /* HIG defaults */ gtk_container_set_border_width (GTK_CONTAINER (dlg), 5); gtk_box_set_spacing (content_area, 2); /* 2 * 5 + 2 = 12 */ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); gtk_box_set_spacing (GTK_BOX (action_area), 4); g_signal_connect (dlg, "response", G_CALLBACK (dialog_response_handler), NULL); builder = gtk_builder_new (); gtk_builder_add_objects_from_resource (builder, "/org/gnome/gtranslator/ui/gtr-preferences-dialog.ui", root_objects, NULL); priv->notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook")); g_object_ref (priv->notebook); priv->warn_if_contains_fuzzy_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "warn_if_fuzzy_checkbutton")); priv->autosave_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_checkbutton")); priv->autosave_interval_spinbutton = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_interval_spinbutton")); priv->autosave_grid = GTK_WIDGET (gtk_builder_get_object (builder, "autosave_grid")); priv->create_backup_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "create_backup_checkbutton")); priv->highlight_syntax_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "highlight_checkbutton")); priv->visible_whitespace_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "visible_whitespace_checkbutton")); priv->use_custom_font_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "use_custom_font_checkbutton")); priv->editor_font_fontbutton = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_fontbutton")); priv->editor_font_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "editor_font_hbox")); priv->unmark_fuzzy_when_changed_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "unmark_fuzzy_checkbutton")); priv->spellcheck_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "spellcheck_checkbutton")); priv->profile_treeview = GTK_WIDGET (gtk_builder_get_object (builder, "profile_treeview")); priv->add_button = GTK_WIDGET (gtk_builder_get_object (builder, "add-button")); priv->edit_button = GTK_WIDGET (gtk_builder_get_object (builder, "edit-button")); priv->delete_button = GTK_WIDGET (gtk_builder_get_object (builder, "delete-button")); profiles_toolbar = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-toolbar")); profiles_scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "profiles-scrolledwindow")); priv->plugins_box = GTK_WIDGET (gtk_builder_get_object (builder, "plugins_box")); g_object_unref (builder); gtk_box_pack_start (content_area, priv->notebook, FALSE, FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5); context = gtk_widget_get_style_context (profiles_scrolled_window); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); context = gtk_widget_get_style_context (profiles_toolbar); gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); setup_files_pages (dlg); setup_editor_pages (dlg); setup_profile_pages (dlg); setup_plugin_pages (dlg); }
int main(int argc, char* argv[]) { gtk_init(&argc,&argv); // check the correct BASS was loaded if (HIWORD(BASS_GetVersion())!=BASSVERSION) { Error("An incorrect version of BASS was loaded"); return 0; } // initialize BASS if (!BASS_Init(-1,44100,0,NULL,NULL)) { Error("Can't initialize device"); return 0; } if (!PlayFile()) { // start a file playing BASS_Free(); return 0; } // create the window win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(win),GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW(win),FALSE); gtk_window_set_title(GTK_WINDOW(win),"BASS spectrum example (click to toggle mode)"); g_signal_connect(win,"destroy",GTK_SIGNAL_FUNC(WindowDestroy),NULL); GtkWidget *ebox=gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(win),ebox); g_signal_connect(ebox,"button-release-event",GTK_SIGNAL_FUNC(WindowButtonRelease),NULL); // create the bitmap specpb=gdk_pixbuf_new(GDK_COLORSPACE_RGB,FALSE,8,SPECWIDTH,SPECHEIGHT); speci=gtk_image_new_from_pixbuf(specpb); gtk_container_add(GTK_CONTAINER(ebox),speci); { // setup palette RGB *pal=palette; int a; memset(palette,0,sizeof(palette)); for (a=1;a<128;a++) { pal[a].rgbGreen=256-2*a; pal[a].rgbRed=2*a; } for (a=0;a<32;a++) { pal[128+a].rgbBlue=8*a; pal[128+32+a].rgbBlue=255; pal[128+32+a].rgbRed=8*a; pal[128+64+a].rgbRed=255; pal[128+64+a].rgbBlue=8*(31-a); pal[128+64+a].rgbGreen=8*a; pal[128+96+a].rgbRed=255; pal[128+96+a].rgbGreen=255; pal[128+96+a].rgbBlue=8*a; } } // setup update timer (40hz) g_timeout_add(25,UpdateSpectrum,NULL); gtk_widget_show_all(win); gtk_main(); gdk_pixbuf_unref(specpb); BASS_Free(); return 0; }
static void popup_create_auth(gtk_ui_t *gu, prop_t *p) { GtkWidget *vbox, *hbox; GtkWidget *win; GtkWidget *l, *e, *w; prop_sub_t *s; popup_t *pop = calloc(1, sizeof(popup_t)); pop->p = prop_ref_inc(p); LIST_INSERT_HEAD(&gu->popups, pop, link); /* The window */ pop->win = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(win), "Authentication request"); gtk_window_set_default_size(GTK_WINDOW(win), 400, 180); gtk_window_set_resizable(GTK_WINDOW(win), FALSE); gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT); // gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(gu->gu_window)); /* Vbox */ vbox = gtk_vbox_new(FALSE, 1); gtk_container_set_border_width(GTK_CONTAINER(vbox), 1); gtk_container_add(GTK_CONTAINER(win), vbox); /* ID label */ l = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(vbox), l, FALSE, TRUE, 0); s = prop_subscribe(0, PROP_TAG_NAME("self", "id"), PROP_TAG_CALLBACK_STRING, gu_subscription_set_label, l, PROP_TAG_COURIER, glibcourier, PROP_TAG_NAMED_ROOT, p, "self", NULL); gu_unsubscribe_on_destroy(GTK_OBJECT(l), s); /* Reason label */ l = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(vbox), l, FALSE, TRUE, 0); s = prop_subscribe(0, PROP_TAG_NAME("self", "reason"), PROP_TAG_CALLBACK_STRING, gu_subscription_set_label, l, PROP_TAG_COURIER, glibcourier, PROP_TAG_NAMED_ROOT, p, "self", NULL); gu_unsubscribe_on_destroy(GTK_OBJECT(l), s); /* Username */ hbox = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); l = gtk_label_new("Username:"******"activate", G_CALLBACK(auth_ok), pop); /* Password */ hbox = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); l = gtk_label_new("Password:"******"activate", G_CALLBACK(auth_ok), pop); /* Separator */ w = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), w, FALSE, TRUE, 0); /* Action buttons */ hbox = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); w = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_container_add(GTK_CONTAINER(hbox), w); g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(auth_ok), pop); w = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_container_add(GTK_CONTAINER(hbox), w); g_signal_connect(G_OBJECT(w), "clicked", G_CALLBACK(auth_cancel), pop); gtk_widget_show_all(win); }
int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *table1; GtkWidget *menuBar; GtkWidget *noteBook; GtkWidget *MenuItemTask; const char *title[3] = {"总体信息","进程信息","系统信息"}; GtkWidget *label[Nsize];//页面标题 GtkWidget *frame[Nsize];//页面框架 gtk_init(&argc, &argv);//初始化命令行参数 虽不使用但是必需 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window),"任务管理器"); gtk_widget_set_usize(window, 600, 600); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (window), TRUE); gtk_container_set_border_width(GTK_CONTAINER(window),5); table1 = gtk_table_new(11,11,TRUE); gtk_container_add(GTK_CONTAINER(window),table1); menuBar = gtk_menu_bar_new(); gtk_table_attach_defaults(GTK_TABLE(table1), menuBar,0,11,0,1); MenuItemTask = CreateMenuItem(menuBar, "进程"); CreateMenuTask(MenuItemTask); noteBook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(noteBook),GTK_POS_TOP);//设置notebook的格式 gtk_table_attach_defaults(GTK_TABLE(table1), noteBook, 0, 11, 1, 10); gint i; for(i = 0; i < Nsize; i++) { label[i] = gtk_label_new(title[i]); frame[i] = gtk_frame_new(NULL); gtk_container_set_border_width(GTK_CONTAINER(frame[i]), 5); gtk_widget_set_size_request(frame[i],450,450); gtk_notebook_append_page(GTK_NOTEBOOK(noteBook),frame[i],label[i]); table2[i] = gtk_table_new(12,12,TRUE); gtk_container_add(GTK_CONTAINER(frame[i]),table2[i]); } time_label = gtk_label_new(""); gtk_timeout_add(1000, (GtkFunction)get_time, NULL); gtk_table_attach_defaults(GTK_TABLE(table1), time_label, 8,10,1,2); cpu_label = gtk_label_new(""); gtk_timeout_add(3000, (GtkFunction)get_cpu_rate, NULL); gtk_table_attach_defaults(GTK_TABLE(table1), cpu_label, 1,3,10,11); mem_label = gtk_label_new(""); gtk_timeout_add(3000, (GtkFunction)get_mem_rate, NULL); gtk_table_attach_defaults(GTK_TABLE(table1), mem_label, 8,10,10,11); process_num_label = gtk_label_new(""); gtk_timeout_add(1000, (GtkFunction)get_process_num, NULL); gtk_table_attach_defaults(GTK_TABLE(table1), process_num_label, 4,7,10,11); pro_init(); gtk_timeout_add(3000, (GtkFunction)pro_fill, NULL); info_init(); drawlines_init(); gtk_timeout_add(1000, (GtkFunction)lines_refresh, NULL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);//可关闭 gtk_widget_show_all(window); gtk_main();//主事件循环 return 0; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *main_hbox; GtkWidget *vseparator; GtkWidget *button; GtkWidget *main_vbox; GtkWidget *menubar; GtkWidget *vbox; GtkWidget *label; GtkAccelGroup *accel_group; PangoFontDescription *font_desc; int i; char *p; p = progname = argv[0]; while (*p) { if (*p == '/') progname = p+1; p++; } gtk_init (&argc, &argv); for (i=1; i<argc; i++) { if (!strcmp(argv[i], "--data-file") || !strcmp(argv[i], "-f")) { i++; if (i < argc) data_file = argv[i]; else usage(); } else { usage(); } } window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable (GTK_WINDOW (window), TRUE); gtk_window_set_default_size (GTK_WINDOW (window), 350, 350); g_signal_connect (window, "destroy", G_CALLBACK (exit_callback), NULL); gtk_window_set_title (GTK_WINDOW(window), "KanjiPad"); main_vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), main_vbox); gtk_widget_show (main_vbox); /* Menu */ GtkActionGroup *action_group; /* Packing group for our Actions */ GtkUIManager *menu_manager; /* The magic widget! */ GError *error; /* For reporting exceptions or errors */ GtkWidget *toolbar; /* The actual toolbar */ action_group = gtk_action_group_new ("MainMenu"); gtk_action_group_add_actions (action_group, entries, n_entries, NULL); gtk_action_group_add_toggle_actions (action_group, toggle_entries, n_toggle_entries, NULL); menu_manager = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (menu_manager, action_group, 0); error = NULL; gtk_ui_manager_add_ui_from_file (menu_manager, "ui.xml", &error); if (error){ g_message ("building menus failed: %s", error->message); g_error_free (error); } //Add the menu bar menubar = gtk_ui_manager_get_widget (menu_manager, "/MainMenu"); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, FALSE, 0); /*accel_group = gtk_accel_group_new (); factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group); gtk_item_factory_create_items (factory, nmenu_items, menu_items, NULL);*/ /* create a menubar */ /*menubar = gtk_item_factory_get_widget (factory, "<main>"); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar);*/ /* Install the accelerator table in the main window */ //gtk_window_add_accel_group (GTK_WINDOW (window), accel_group); main_hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER(window), main_hbox); gtk_box_pack_start (GTK_BOX(main_vbox), main_hbox, TRUE, TRUE, 0); gtk_widget_show (main_hbox); /* toolbar = gtk_ui_manager_get_widget (menu_manager, "/MainToolbar"); gtk_box_pack_start (GTK_BOX (main_hbox), toolbar, FALSE, FALSE, 0); gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (menu_manager)); */ /* Area for user to draw characters in */ pad_area = pad_area_create (); gtk_box_pack_start (GTK_BOX (main_hbox), pad_area->widget, TRUE, TRUE, 0); gtk_widget_show (pad_area->widget); vseparator = gtk_vseparator_new(); gtk_box_pack_start (GTK_BOX (main_hbox), vseparator, FALSE, FALSE, 0); gtk_widget_show (vseparator); /* Area in which to draw guesses */ vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); karea = gtk_drawing_area_new(); g_signal_connect (karea, "configure_event", G_CALLBACK (karea_configure_event), NULL); g_signal_connect (karea, "expose_event", G_CALLBACK (karea_expose_event), NULL); g_signal_connect (karea, "button_press_event", G_CALLBACK (karea_button_press_event), NULL); gtk_widget_set_events (karea, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); #ifdef G_OS_WIN32 font_desc = pango_font_description_from_string ("MS Gothic 18"); #else font_desc = pango_font_description_from_string ("Sans 18"); #endif gtk_widget_modify_font (karea, font_desc); gtk_box_pack_start (GTK_BOX (vbox), karea, TRUE, TRUE, 0); gtk_widget_show (karea); /* Buttons */ label = gtk_label_new ("\xe5\xbc\x95"); /* We have to set the alignment here, since GTK+ will fail * to get the width of the string appropriately... */ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); lookup_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (look_up_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); label = gtk_label_new ("\xe6\x88\xbb"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); undo_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (undo_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); label = gtk_label_new ("\xe6\xb6\x88"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_modify_font (label, font_desc); gtk_widget_show (label); clear_button = button = gtk_button_new (); gtk_container_add (GTK_CONTAINER (button), label); g_signal_connect (button, "clicked", G_CALLBACK (clear_callback), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gtk_widget_show(window); pango_font_description_free (font_desc); init_engine(); update_sensitivity (); gtk_main(); return 0; }
static void remmina_init_dialog_init(RemminaInitDialog *dialog) { GtkWidget *hbox = NULL; GtkWidget *widget; dialog->image = NULL; dialog->content_vbox = NULL; dialog->status_label = NULL; dialog->mode = REMMINA_INIT_MODE_CONNECTING; dialog->title = NULL; dialog->status = NULL; dialog->username = NULL; dialog->domain = NULL; dialog->password = NULL; dialog->save_password = FALSE; dialog->cacert = NULL; dialog->cacrl = NULL; dialog->clientcert = NULL; dialog->clientkey = NULL; gtk_dialog_add_buttons(GTK_DIALOG(dialog), _("_Cancel"), GTK_RESPONSE_CANCEL, _("_OK"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); /**** Create the dialog content from here ****/ /* Create top-level hbox */ #if GTK_VERSION == 3 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #elif GTK_VERSION == 2 hbox = gtk_hbox_new(FALSE, 4); #endif gtk_widget_show(hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 15); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, TRUE, TRUE, 0); /* Icon */ widget = gtk_image_new_from_icon_name("dialog-information", GTK_ICON_SIZE_DIALOG); gtk_widget_show(widget); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 4); dialog->image = widget; /* Create vbox for other dialog content */ #if GTK_VERSION == 3 widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); #elif GTK_VERSION == 2 widget = gtk_vbox_new(FALSE, 4); #endif gtk_widget_show(widget); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 4); dialog->content_vbox = widget; /* Entries */ widget = gtk_label_new(dialog->title); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_widget_show(widget); gtk_box_pack_start(GTK_BOX(dialog->content_vbox), widget, TRUE, TRUE, 4); dialog->status_label = widget; g_signal_connect(G_OBJECT(dialog), "destroy", G_CALLBACK(remmina_init_dialog_destroy), NULL); remmina_widget_pool_register(GTK_WIDGET(dialog)); }
static void gw_settingswindow_constructed (GObject *object) { //Declarations GwSettingsWindow *window; GwSettingsWindowPrivate *priv; GwApplication *application; LwDictionaryList *dictionarylist; GtkAccelGroup *accelgroup; //Chain the parent class { G_OBJECT_CLASS (gw_settingswindow_parent_class)->constructed (object); } //Initializations window = GW_SETTINGSWINDOW (object); priv = window->priv; accelgroup = gw_window_get_accel_group (GW_WINDOW (window)); application = gw_window_get_application (GW_WINDOW (window)); dictionarylist = LW_DICTIONARYLIST (gw_application_get_installed_dictionarylist (application)); gw_settingswindow_map_actions (G_ACTION_MAP (window), window); priv->manage_dictionaries_treeview = GTK_TREE_VIEW (gw_window_get_object (GW_WINDOW (window), "dictionary_treeview")); priv->notebook = GTK_NOTEBOOK (gw_window_get_object (GW_WINDOW (window), "settings_notebook")); priv->close_button = GTK_BUTTON (gw_window_get_object (GW_WINDOW (window), "close_button")); priv->spellcheck_checkbutton = GTK_TOGGLE_BUTTON (gw_window_get_object (GW_WINDOW (window), "spellcheck_checkbutton")); priv->please_install_dictionary_hbox = GTK_BOX (gw_window_get_object (GW_WINDOW (window), "please_install_dictionary_hbox")); priv->custom_font_fontbutton = GTK_FONT_BUTTON (gw_window_get_object (GW_WINDOW (window), "custom_font_fontbutton")); priv->match_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "match_foreground_colorbutton")); priv->match_background = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "match_background_colorbutton")); priv->comment_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "comment_foreground_colorbutton")); priv->header_foreground = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "header_foreground_colorbutton")); priv->header_background = GTK_COLOR_BUTTON (gw_window_get_object (GW_WINDOW (window), "header_background_colorbutton")); priv->system_document_font_hbox = GTK_BOX (gw_window_get_object (GW_WINDOW (window), "system_document_font_hbox")); priv->system_font_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "system_font_checkbutton")); priv->search_as_you_type_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "search_as_you_type_checkbutton")); priv->romaji_to_kana_combobox = GTK_COMBO_BOX (gw_window_get_object (GW_WINDOW (window), "romaji_to_kana_combobox")); priv->hiragana_to_katakana_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "hiragana_to_katakana_checkbutton")); priv->katakana_to_hiragana_checkbutton = GTK_CHECK_BUTTON (gw_window_get_object (GW_WINDOW (window), "katakana_to_hiragana_checkbutton")); priv->remove_dictionary_toolbutton = GTK_TOOL_BUTTON (gw_window_get_object (GW_WINDOW (window), "remove_dictionary_toolbutton")); gtk_window_set_title (GTK_WINDOW (window), gettext("gWaei Settings")); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (window), TRUE); gtk_window_set_destroy_with_parent (GTK_WINDOW (window), TRUE); gtk_window_set_icon_name (GTK_WINDOW (window), "gwaei"); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gw_settingswindow_remove_signals), NULL); if (g_main_current_source () != NULL) gw_application_block_searches (application); gw_settingswindow_init_styles (window); gw_settingswindow_init_dictionary_treeview (window); if (lw_dictionarylist_get_total (LW_DICTIONARYLIST (dictionarylist)) == 0) gtk_notebook_set_current_page (priv->notebook, 1); gw_settingswindow_check_for_dictionaries (window); #ifdef WITH_HUNSPELL gtk_widget_show (GTK_WIDGET (priv->spellcheck_checkbutton)); #else gtk_widget_hide (GTK_WIDGET (priv->spellcheck_checkbutton)); #endif gw_settingswindow_attach_signals (window); gtk_widget_add_accelerator (GTK_WIDGET (priv->close_button), "activate", accelgroup, (GDK_KEY_W), GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); gtk_widget_add_accelerator (GTK_WIDGET (priv->close_button), "activate", accelgroup, (GDK_KEY_Escape), 0, GTK_ACCEL_VISIBLE); gw_window_unload_xml (GW_WINDOW (window)); }
int DialogExecute(GtkWidget *parent, void *dialog) { GtkWidget *dlg, *win_ptr, *btn; struct DialogType *data; gint res_id, lockstate; lockstate = DnDLock; DnDLock = TRUE; data = (struct DialogType *) dialog; if (data->widget && (data->parent != parent)) { #if 1 gtk_window_set_transient_for(GTK_WINDOW(data->widget), GTK_WINDOW(parent)); data->parent = parent; #else gtk_widget_destroy(data->widget); reset_event(); data->widget = NULL; #endif } if (data->widget == NULL) { dlg = gtk_dialog_new_with_buttons(_(data->resource), GTK_WINDOW(parent), #if GTK_CHECK_VERSION(3, 12, 0) && USE_HEADER_BAR GTK_DIALOG_USE_HEADER_BAR | #endif GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, _("_Cancel"), GTK_RESPONSE_CANCEL, NULL); gtk_window_set_resizable(GTK_WINDOW(dlg), TRUE); g_signal_connect(dlg, "delete-event", G_CALLBACK(dialog_delete_cb), data); g_signal_connect(dlg, "destroy", G_CALLBACK(dialog_destroyed_cb), data); g_signal_connect(dlg, "key-press-event", G_CALLBACK(dialog_key_down_cb), NULL); data->parent = parent; data->widget = dlg; data->vbox = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dlg))); data->show_cancel = TRUE; data->ok_button = _("_OK"); gtk_window_set_title(GTK_WINDOW(dlg), _(data->resource)); data->SetupWindow(dlg, data, TRUE); gtk_dialog_add_button(GTK_DIALOG(dlg), data->ok_button, GTK_RESPONSE_OK); if (! data->show_cancel) { btn = gtk_dialog_get_widget_for_response(GTK_DIALOG(dlg), GTK_RESPONSE_CANCEL); gtk_widget_hide(btn); } gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK); } else { dlg = data->widget; data->SetupWindow(dlg, data, FALSE); } gtk_widget_hide(dlg); gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK); data->widget = dlg; data->ret = IDLOOP; gtk_widget_show(dlg); win_ptr = get_current_window(); set_current_window(dlg); if (data->focus) gtk_widget_grab_focus(data->focus); while (data->ret == IDLOOP) { res_id = ndialog_run(dlg); if (res_id < 0) { switch (res_id) { case GTK_RESPONSE_OK: data->ret = IDOK; break; default: data->ret = IDCANCEL; break; } } else { data->ret = res_id; } if (data->CloseWindow) { data->CloseWindow(dlg, data); } } // gtk_widget_destroy(dlg); // data->widget = NULL; set_current_window(win_ptr); gtk_widget_hide(dlg); reset_event(); DnDLock = lockstate; return data->ret; }
static void uim_cand_win_horizontal_gtk_init (UIMCandWinHorizontalGtk *horizontal_cwin) { gint col; GtkWidget *viewport; UIMCandWinGtk *cwin; cwin = UIM_CAND_WIN_GTK(horizontal_cwin); horizontal_cwin->buttons = g_ptr_array_new(); horizontal_cwin->selected = NULL; #if GTK_CHECK_VERSION(3, 4, 0) cwin->view = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(cwin->view), 10); #else cwin->view = gtk_table_new(1, DEFAULT_NR_CELLS, FALSE); gtk_table_set_col_spacings(GTK_TABLE(cwin->view), 10); #endif viewport = gtk_viewport_new(NULL, NULL); gtk_container_add(GTK_CONTAINER(viewport), cwin->view); gtk_container_add(GTK_CONTAINER(cwin->scrolled_window), viewport); gtk_container_set_resize_mode(GTK_CONTAINER(viewport), GTK_RESIZE_PARENT); for (col = 0; col < DEFAULT_NR_CELLS; col++) { GtkWidget *button; GtkWidget *label; struct index_button *idxbutton; button = gtk_event_box_new(); gtk_event_box_set_above_child(GTK_EVENT_BOX(button), TRUE); label = gtk_label_new(""); gtk_container_add(GTK_CONTAINER(button), label); scale_label(GTK_EVENT_BOX(button), PANGO_SCALE_LARGE); g_signal_connect(button, "button-press-event", G_CALLBACK(button_clicked), horizontal_cwin); #if GTK_CHECK_VERSION(2, 90, 0) g_signal_connect_after(label, "draw", G_CALLBACK(label_draw), horizontal_cwin); #else g_signal_connect_after(label, "expose-event", G_CALLBACK(label_exposed), horizontal_cwin); #endif #if GTK_CHECK_VERSION(3, 4, 0) gtk_widget_set_hexpand(button, TRUE); gtk_widget_set_vexpand(button, TRUE); gtk_grid_attach(GTK_GRID(cwin->view), button, col, 0, 1, 1); #else gtk_table_attach_defaults(GTK_TABLE(cwin->view), button, col, col + 1, 0, 1); #endif idxbutton = g_malloc(sizeof(struct index_button)); if (idxbutton) { idxbutton->button = GTK_EVENT_BOX(button); clear_button(idxbutton, col); } g_ptr_array_add(horizontal_cwin->buttons, idxbutton); } gtk_widget_show_all(cwin->view); gtk_widget_show(viewport); gtk_widget_set_size_request(cwin->num_label, DEFAULT_MIN_WINDOW_WIDTH, -1); gtk_window_set_default_size(GTK_WINDOW(cwin), DEFAULT_MIN_WINDOW_WIDTH, -1); gtk_window_set_resizable(GTK_WINDOW(cwin), FALSE); }