static void gsd_ldsm_dialog_init (GsdLdsmDialog *dialog) { GtkWidget *main_vbox, *text_vbox, *hbox; GtkWidget *image; dialog->priv = GSD_LDSM_DIALOG_GET_PRIVATE (dialog); main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); /* Set up all the window stuff here */ gtk_window_set_title (GTK_WINDOW (dialog), _("Low Disk Space")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_WARNING); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE); gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); /* Create the image */ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); /* Create the labels */ dialog->priv->primary_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (dialog->priv->primary_label), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (dialog->priv->primary_label), FALSE); gtk_misc_set_alignment (GTK_MISC (dialog->priv->primary_label), 0.0, 0.0); dialog->priv->secondary_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (dialog->priv->secondary_label), TRUE); gtk_label_set_single_line_mode (GTK_LABEL (dialog->priv->secondary_label), FALSE); gtk_misc_set_alignment (GTK_MISC (dialog->priv->secondary_label), 0.0, 0.0); /* Create the check button to ignore future warnings */ dialog->priv->ignore_check_button = gtk_check_button_new (); /* The button should be inactive if the dialog was just called. * I suppose it could be possible for the user to manually edit the GSettings key between * the mount being checked and the dialog appearing, but I don't think it matters * too much */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->ignore_check_button), FALSE); g_signal_connect (dialog->priv->ignore_check_button, "toggled", G_CALLBACK (ignore_check_button_toggled_cb), dialog); /* Now set up the dialog's GtkBox's' */ gtk_box_set_spacing (GTK_BOX (main_vbox), 14); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); text_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->primary_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->secondary_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (text_vbox), dialog->priv->ignore_check_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), text_vbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); /* Set up the action area */ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 6); gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), 5); gtk_widget_show_all (hbox); }
void mobile_connection_new (GtkWindow *parent, const char *detail, NMRemoteSettings *settings, PageNewConnectionResultFunc result_func, gpointer user_data) { NMAMobileWizard *wizard; WizardInfo *info; GtkWidget *dialog, *vbox, *gsm_radio, *cdma_radio, *label, *content, *alignment; GtkWidget *hbox, *image; gint response; NMAMobileWizardAccessMethod method; info = g_malloc0 (sizeof (WizardInfo)); info->result_func = result_func; info->settings = g_object_ref (settings); info->user_data = user_data; wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE, new_connection_mobile_wizard_done, info); if (wizard) { nma_mobile_wizard_present (wizard); return; } /* Fall back to just asking for GSM vs. CDMA */ dialog = gtk_dialog_new_with_buttons (_("Select Mobile Broadband Provider Type"), parent, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_signal_connect (dialog, "delete-event", G_CALLBACK (cancel_dialog), NULL); gtk_window_set_icon_name (GTK_WINDOW (dialog), "nm-device-wwan"); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); alignment = gtk_alignment_new (0, 0, 0.5, 0.5); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12); gtk_box_pack_start (GTK_BOX (content), alignment, TRUE, FALSE, 6); #if GTK_CHECK_VERSION (3,1,6) hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); #else hbox = gtk_hbox_new (FALSE, 6); #endif gtk_container_add (GTK_CONTAINER (alignment), hbox); image = gtk_image_new_from_icon_name ("nm-device-wwan", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); gtk_misc_set_padding (GTK_MISC (image), 0, 6); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 6); #if GTK_CHECK_VERSION (3,1,6) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); #else vbox = gtk_vbox_new (FALSE, 6); #endif gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0); label = gtk_label_new (_("Select the technology your mobile broadband provider uses. If you are unsure, ask your provider.")); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 12); gsm_radio = gtk_radio_button_new_with_mnemonic (NULL, _("My provider uses _GSM-based technology (i.e. GPRS, EDGE, UMTS, HSDPA)")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gsm_radio), TRUE); gtk_box_pack_start (GTK_BOX (vbox), gsm_radio, FALSE, FALSE, 6); /* Translators: CDMA has 'D' accelerator key; 'C' collides with 'Cancel' button. You may need to change it according to your language. */ cdma_radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (gsm_radio), _("My provider uses C_DMA-based technology (i.e. 1xRTT, EVDO)")); gtk_box_pack_start (GTK_BOX (vbox), cdma_radio, FALSE, FALSE, 6); gtk_widget_show_all (dialog); memset (&method, 0, sizeof (method)); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cdma_radio))) { method.devtype = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO; method.provider_name = _("CDMA"); } else { method.devtype = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS; method.provider_name = _("GSM"); } } gtk_widget_destroy (dialog); new_connection_mobile_wizard_done (NULL, (response != GTK_RESPONSE_OK), (response == GTK_RESPONSE_OK) ? &method : NULL, info); }
static GtkWidget * buildExplorer ( void *pData ) { GtkWidget *dialog; GtkWidget *vbox, *buttonBox, *closeButton, *statusBar; char windowTitle[strlen(PROGRAM_NAME) + strlen(TAG_EVENTOR_EXPLORER_WINDOW_TITLE) + 10]; GtkTreeViewColumn *column; GtkCellRenderer *renderer; dialog = gtk_window_new( GTK_WINDOW_TOPLEVEL ); sprintf(windowTitle, "%s%s", PROGRAM_NAME, TAG_EVENTOR_EXPLORER_WINDOW_TITLE ); gtk_window_set_title( (GtkWindow *)dialog, windowTitle ); /* set the icon for the window */ gtk_window_set_icon_name( (GtkWindow *)dialog, ICON_NAME_CONNECTED ); /* When the window is given the "delete" signal (this is given * by the window manager, usually by the "close" option, or on the * titlebar) */ g_signal_connect (G_OBJECT (dialog), "delete_event", G_CALLBACK (deleteSignalHandler), NULL); /* Here we connect the "destroy" event to a signal handler. * This event occurs when we call gtk_widget_destroy() on the window, * or if we return FALSE in the "delete_event" callback. */ g_signal_connect (G_OBJECT (dialog), "destroy", G_CALLBACK (destroy), NULL); /******************************* Vertical Box ***********************************/ /* vertical box to hold things, Not homogeneous sizes and spaceing 0 */ vbox = gtk_vbox_new(FALSE, 0); /* This packs the vbox into the window (a gtk container). */ gtk_container_add (GTK_CONTAINER (dialog), vbox); /****************************** Tree View ***************************************/ /* Create a model for the tree view. with two text columns */ store = gtk_tree_store_new ( N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); /* custom function to fill the model with data */ explorerFillTreeModel(); /* Create a view */ treeView = gtk_tree_view_new_with_model ( GTK_TREE_MODEL ( store ) ); /* The view now holds a reference. We can get rid of our own reference */ g_object_unref (G_OBJECT (store)); /* Create a columnfor the object name */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Object", renderer, "text", OBJECT_COLUMN, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (treeView), column); /* Second column.. description of object */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("Description", renderer, "text", DESCRIPTION_COLUMN, NULL); gtk_tree_view_append_column( GTK_TREE_VIEW (treeView), column); gtk_tree_view_set_enable_tree_lines( GTK_TREE_VIEW(treeView), TRUE ); gtk_tree_view_expand_all( GTK_TREE_VIEW( treeView ) ); /************** Pack in Tree View *********************************/ /* This packs the scrolled window into the vbox (a gtk container). */ gtk_box_pack_start( GTK_BOX(vbox), treeView, TRUE, TRUE, 3); /******************************* Button Box ***************************************/ /* create the box for the buttons */ buttonBox = gtk_hbox_new( FALSE, 0); /********************************************* Close Button ***********************/ closeButton = gtk_button_new_from_stock( "gtk-close" ); /* This packs the button into the hbutton box (a gtk container). */ gtk_box_pack_end( GTK_BOX(buttonBox), closeButton, FALSE, TRUE, 3); /* When the button receives the "clicked" signal, it will call the * function applyChanges() passing it NULL as its argument. */ /* TODO can't get this signal to work and close things! */ g_signal_connect (G_OBJECT (closeButton), "released", G_CALLBACK (closeSignalHandler), NULL); /**************************** End of buttons **************************************/ /* This packs the hbutton box into the vbox (a gtk container). */ gtk_box_pack_start(GTK_BOX(vbox), buttonBox, FALSE, TRUE, 3); /**************************** Status Bar ******************************************/ /* create the status bar */ statusBar = gtk_statusbar_new(); /* This packs the status bar into the vbox (a gtk container) */ gtk_box_pack_start(GTK_BOX(vbox), statusBar, FALSE, TRUE, 0); return ( dialog ); }
static void status_menu_new_status_message_dialog_run (StatusMenu *self, int option) { std::string presence; std::string status; GSList *clist = NULL; GtkWidget *dialog = NULL; GtkWidget *label = NULL; GtkWidget *entry = NULL; GtkWidget *vbox = NULL; GtkWidget *hbox = NULL; GtkWidget *image = NULL; const char *message = NULL; presence = self->priv->personal_data_settings->get_string ("short-status"); status = self->priv->personal_data_settings->get_string ("long-status"); dialog = gtk_dialog_new_with_buttons (_("Custom Message"), self->priv->parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, false, false, 2); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_window_set_icon_name (GTK_WINDOW (dialog), status_icon_name[option - NUM_STATUS_TYPES - 1]); image = gtk_image_new_from_icon_name (status_icon_name[option - NUM_STATUS_TYPES - 1], GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), image, false, false, 2); label = gtk_label_new (_("Define a custom message:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), label, false, false, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 2); entry = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (entry), true); gtk_box_pack_start (GTK_BOX (vbox), entry, false, false, 2); gtk_widget_show_all (dialog); switch (gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_ACCEPT: message = gtk_entry_get_text (GTK_ENTRY (entry)); clist = self->priv->personal_data_settings->get_slist (status_types_keys[option - NUM_STATUS_TYPES - 1]); if (message && g_strcmp0 (message, "")) { clist = g_slist_append (clist, g_strdup (message)); self->priv->personal_data_settings->set_slist (status_types_keys[option - NUM_STATUS_TYPES - 1], clist); self->priv->personal_details->set_presence_info (status_types_names[option - NUM_STATUS_TYPES - 1], message); } else { status_menu_set_option (self, presence.c_str (), status.c_str ()); } g_slist_foreach (clist, (GFunc) g_free, NULL); g_slist_free (clist); break; default: status_menu_set_option (self, presence.c_str (), status.c_str ()); break; } gtk_widget_destroy (dialog); }
static void show_dialog(MateDACapplet* capplet, const gchar* start_page) { #define get_widget(name) GTK_WIDGET(gtk_builder_get_object(builder, name)) GtkBuilder* builder; guint builder_result; capplet->builder = builder = gtk_builder_new (); if (g_file_test(MATECC_UI_DIR "/mate-default-applications-properties.ui", G_FILE_TEST_EXISTS) != FALSE) { builder_result = gtk_builder_add_from_file(builder, MATECC_UI_DIR "/mate-default-applications-properties.ui", NULL); } else { builder_result = gtk_builder_add_from_file(builder, "./mate-default-applications-properties.ui", NULL); } if (builder_result == 0) { GtkWidget* dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not load the main interface")); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Please make sure that the applet is properly installed")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); exit(EXIT_FAILURE); } capplet->window = get_widget("preferred_apps_dialog"); g_signal_connect(capplet->window, "response", G_CALLBACK(close_cb), capplet); capplet->web_combo_box = get_widget("web_browser_combobox"); capplet->mail_combo_box = get_widget("mail_reader_combobox"); capplet->term_combo_box = get_widget("terminal_combobox"); capplet->media_combo_box = get_widget("media_player_combobox"); capplet->video_combo_box = get_widget("video_combobox"); capplet->visual_combo_box = get_widget("visual_combobox"); capplet->mobility_combo_box = get_widget("mobility_combobox"); capplet->text_combo_box = get_widget("text_combobox"); capplet->file_combo_box = get_widget("filemanager_combobox"); capplet->image_combo_box = get_widget("image_combobox"); capplet->document_combo_box = get_widget("document_combobox"); capplet->word_combo_box = get_widget("word_combobox"); capplet->spreadsheet_combo_box = get_widget("spreadsheet_combobox"); capplet->visual_startup_checkbutton = get_widget("visual_start_checkbutton"); capplet->mobility_startup_checkbutton = get_widget("mobility_start_checkbutton"); g_signal_connect(capplet->window, "screen-changed", G_CALLBACK(screen_changed_cb), capplet); screen_changed_cb(capplet->window, gdk_screen_get_default(), capplet); /* Lists of default applications */ capplet->web_browsers = g_app_info_get_all_for_type("x-scheme-handler/http"); capplet->mail_readers = g_app_info_get_all_for_type("x-scheme-handler/mailto"); capplet->media_players = g_app_info_get_all_for_type("audio/x-vorbis+ogg"); capplet->video_players = g_app_info_get_all_for_type("video/x-ogm+ogg"); capplet->text_editors = g_app_info_get_all_for_type("text/plain"); capplet->image_viewers = g_app_info_get_all_for_type("image/png"); capplet->file_managers = g_app_info_get_all_for_type("inode/directory"); capplet->document_viewers = g_app_info_get_all_for_type("application/pdf"); capplet->word_editors = g_app_info_get_all_for_type("application/msword"); capplet->spreadsheet_editors = g_app_info_get_all_for_type("application/vnd.ms-excel"); capplet->visual_ats = NULL; capplet->visual_ats = fill_list_from_desktop_file (capplet->visual_ats, APPLICATIONSDIR "/orca.desktop"); capplet->visual_ats = g_list_reverse (capplet->visual_ats); capplet->mobility_ats = NULL; capplet->mobility_ats = fill_list_from_desktop_file (capplet->mobility_ats, APPLICATIONSDIR "/dasher.desktop"); capplet->mobility_ats = fill_list_from_desktop_file (capplet->mobility_ats, APPLICATIONSDIR "/gok.desktop"); capplet->mobility_ats = fill_list_from_desktop_file (capplet->mobility_ats, APPLICATIONSDIR "/onboard.desktop"); capplet->mobility_ats = g_list_reverse (capplet->mobility_ats); /* Terminal havent mime types, so check in .desktop files for Categories=TerminalEmulator */ GList *entry; GList *all_apps; capplet->terminals = NULL; all_apps = g_app_info_get_all(); for (entry = all_apps; entry != NULL; entry = g_list_next(entry)) { GDesktopAppInfo* item = (GDesktopAppInfo*) entry->data; if (g_desktop_app_info_get_categories (item) != NULL && g_strrstr (g_desktop_app_info_get_categories (item), "TerminalEmulator")) { capplet->terminals = g_list_prepend (capplet->terminals, item); } } capplet->terminals = g_list_reverse (capplet->terminals); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->web_combo_box), capplet->web_browsers, "x-scheme-handler/http"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mail_combo_box), capplet->mail_readers, "x-scheme-handler/mailto"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->term_combo_box), capplet->terminals, "terminal"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->media_combo_box), capplet->media_players, "audio/x-vorbis+ogg"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->video_combo_box), capplet->video_players, "video/x-ogm+ogg"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->image_combo_box), capplet->image_viewers, "image/png"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->text_combo_box), capplet->text_editors, "text/plain"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->file_combo_box), capplet->file_managers, "inode/directory"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->visual_combo_box), capplet->visual_ats, "visual"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->mobility_combo_box), capplet->mobility_ats, "mobility"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->document_combo_box), capplet->document_viewers, "application/pdf"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->word_combo_box), capplet->word_editors, "application/vnd.oasis.opendocument.text"); fill_combo_box(capplet->icon_theme, GTK_COMBO_BOX(capplet->spreadsheet_combo_box), capplet->spreadsheet_editors, "application/vnd.oasis.opendocument.spreadsheet"); g_signal_connect(capplet->web_combo_box, "changed", G_CALLBACK(web_combo_changed_cb), capplet); g_signal_connect(capplet->mail_combo_box, "changed", G_CALLBACK(mail_combo_changed_cb), capplet); g_signal_connect(capplet->term_combo_box, "changed", G_CALLBACK(terminal_combo_changed_cb), capplet); g_signal_connect(capplet->media_combo_box, "changed", G_CALLBACK(media_combo_changed_cb), capplet); g_signal_connect(capplet->video_combo_box, "changed", G_CALLBACK(video_combo_changed_cb), capplet); g_signal_connect(capplet->visual_combo_box, "changed", G_CALLBACK(visual_combo_changed_cb), capplet); g_signal_connect(capplet->mobility_combo_box, "changed", G_CALLBACK(mobility_combo_changed_cb), capplet); g_signal_connect(capplet->image_combo_box, "changed", G_CALLBACK(image_combo_changed_cb), capplet); g_signal_connect(capplet->text_combo_box, "changed", G_CALLBACK(text_combo_changed_cb), capplet); g_signal_connect(capplet->file_combo_box, "changed", G_CALLBACK(file_combo_changed_cb), capplet); g_signal_connect(capplet->document_combo_box, "changed", G_CALLBACK(document_combo_changed_cb), capplet); g_signal_connect(capplet->word_combo_box, "changed", G_CALLBACK(word_combo_changed_cb), capplet); g_signal_connect(capplet->spreadsheet_combo_box, "changed", G_CALLBACK(spreadsheet_combo_changed_cb), capplet); g_settings_bind (capplet->mobility_settings, MOBILITY_STARTUP_KEY, capplet->mobility_startup_checkbutton, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (capplet->visual_settings, VISUAL_STARTUP_KEY, capplet->visual_startup_checkbutton, "active", G_SETTINGS_BIND_DEFAULT); gtk_window_set_icon_name(GTK_WINDOW (capplet->window), "preferences-desktop-default-applications"); if (start_page != NULL) { gchar* page_name; GtkWidget* w; page_name = g_strconcat (start_page, "_vbox", NULL); w = get_widget(page_name); if (w != NULL) { GtkNotebook* nb; gint pindex; nb = GTK_NOTEBOOK(get_widget("preferred_apps_notebook")); pindex = gtk_notebook_page_num(nb, w); if (pindex != -1) { gtk_notebook_set_current_page(nb, pindex); } } g_free(page_name); } gtk_widget_show(capplet->window); #undef get_widget }
void fm_find_files( const char** search_dirs ) { FindFile* data = g_slice_new0(FindFile); GtkTreeIter it; GtkTreeViewColumn* col; GtkWidget *add_folder_btn, *remove_folder_btn, *img; GtkBuilder* builder = _gtk_builder_new_from_file( PACKAGE_UI_DIR "/find-files.ui", NULL ); data->win = (GtkWidget*)gtk_builder_get_object( builder, "win" ); g_object_set_data_full( G_OBJECT( data->win ), "find-files", data, (GDestroyNotify)free_data ); GdkPixbuf* icon = NULL; GtkIconTheme* theme = gtk_icon_theme_get_default(); if ( theme ) icon = gtk_icon_theme_load_icon( theme, "spacefm-find", 48, 0, NULL ); if ( icon ) { gtk_window_set_icon( GTK_WINDOW( data->win ), icon ); g_object_unref( icon ); } else gtk_window_set_icon_name( GTK_WINDOW( data->win ), GTK_STOCK_FIND ); /* search criteria pane */ data->search_criteria = (GtkWidget*)gtk_builder_get_object( builder, "search_criteria" ); data->fn_pattern = (GtkWidget*)gtk_builder_get_object( builder, "fn_pattern" ); data->fn_pattern_entry = gtk_bin_get_child( GTK_BIN( data->fn_pattern ) ); data->fn_case_sensitive = (GtkWidget*)gtk_builder_get_object( builder, "fn_case_sensitive" ); gtk_entry_set_activates_default( (GtkEntry*)data->fn_pattern_entry, TRUE ); /* file content */ data->fc_pattern = (GtkWidget*)gtk_builder_get_object( builder, "fc_pattern" ); data->fc_case_sensitive = (GtkWidget*)gtk_builder_get_object( builder, "fc_case_sensitive" ); data->fc_use_regexp = (GtkWidget*)gtk_builder_get_object( builder, "fc_use_regexp" ); /* advanced options */ data->search_hidden = (GtkWidget*)gtk_builder_get_object( builder, "search_hidden" ); /* size & date */ data->use_size_lower = (GtkWidget*)gtk_builder_get_object( builder, "use_size_lower" ); data->use_size_upper = (GtkWidget*)gtk_builder_get_object( builder, "use_size_upper" ); data->size_lower = (GtkWidget*)gtk_builder_get_object( builder, "size_lower" ); data->size_upper = (GtkWidget*)gtk_builder_get_object( builder, "size_upper" ); data->size_lower_unit = (GtkWidget*)gtk_builder_get_object( builder, "size_lower_unit" ); data->size_upper_unit = (GtkWidget*)gtk_builder_get_object( builder, "size_upper_unit" ); g_signal_connect( data->use_size_lower, "toggled", G_CALLBACK( on_use_size_lower_toggled ), data ); g_signal_connect( data->use_size_upper, "toggled", G_CALLBACK( on_use_size_upper_toggled ), data ); on_use_size_lower_toggled( data->use_size_lower, data ); on_use_size_upper_toggled( data->use_size_upper, data ); data->date_limit = (GtkWidget*)gtk_builder_get_object( builder, "date_limit" ); data->date1 = (GtkWidget*)gtk_builder_get_object( builder, "date1" ); data->date2 = (GtkWidget*)gtk_builder_get_object( builder, "date2" ); g_signal_connect( data->date_limit, "changed", G_CALLBACK( on_date_limit_changed ), data ); /* file types */ data->all_files = (GtkWidget*)gtk_builder_get_object( builder, "all_files" ); data->text_files = (GtkWidget*)gtk_builder_get_object( builder, "text_files" ); data->img_files = (GtkWidget*)gtk_builder_get_object( builder, "img_files" ); data->audio_files = (GtkWidget*)gtk_builder_get_object( builder, "audio_files" ); data->video_files = (GtkWidget*)gtk_builder_get_object( builder, "video_files" ); /* places */ data->places_list = gtk_list_store_new( 1, G_TYPE_STRING ); data->places_view = (GtkWidget*)gtk_builder_get_object( builder, "places_view" ); add_folder_btn = (GtkWidget*)gtk_builder_get_object( builder, "add_folder_btn" ); remove_folder_btn = (GtkWidget*)gtk_builder_get_object( builder, "remove_folder_btn" ); data->include_sub = (GtkWidget*)gtk_builder_get_object( builder, "include_sub" ); if( search_dirs ) { const char** dir; for( dir = search_dirs; *dir; ++dir ) { if( g_file_test( *dir, G_FILE_TEST_IS_DIR ) ) gtk_list_store_insert_with_values( data->places_list, &it, 0, 0, *dir, -1 ); } } gtk_tree_view_set_model( (GtkTreeView*)data->places_view, (GtkTreeModel*)data->places_list ); g_object_unref( data->places_list ); col = gtk_tree_view_column_new_with_attributes(NULL, gtk_cell_renderer_text_new(), "text", 0, NULL ); gtk_tree_view_append_column( (GtkTreeView*)data->places_view, col ); g_signal_connect(add_folder_btn, "clicked", G_CALLBACK( on_add_search_folder ), data ); g_signal_connect(remove_folder_btn, "clicked", G_CALLBACK( on_remove_search_folder ), data ); /* search result pane */ data->search_result = (GtkWidget*)gtk_builder_get_object( builder, "search_result" ); /* replace the problematic GtkTreeView with ExoTreeView */ data->result_view = exo_tree_view_new(); if( app_settings.single_click ) { exo_tree_view_set_single_click( EXO_TREE_VIEW( data->result_view ), TRUE ); exo_tree_view_set_single_click_timeout( EXO_TREE_VIEW( data->result_view ), SINGLE_CLICK_TIMEOUT ); } gtk_widget_show( data->result_view ); gtk_container_add( (GtkContainer*)gtk_builder_get_object(builder, "result_scroll"), data->result_view ); init_search_result( data ); g_signal_connect(data->result_view, "button-press-event", G_CALLBACK( on_view_button_press ), data ); /* buttons */ data->start_btn = (GtkWidget*)gtk_builder_get_object( builder, "start_btn" ); data->stop_btn = (GtkWidget*)gtk_builder_get_object( builder, "stop_btn" ); data->again_btn = (GtkWidget*)gtk_builder_get_object( builder, "again_btn" ); img = gtk_image_new_from_icon_name( GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON ); gtk_button_set_image( (GtkButton*)data->again_btn, img ); g_signal_connect(data->start_btn, "clicked", G_CALLBACK( on_start_search ), data ); g_signal_connect(data->stop_btn, "clicked", G_CALLBACK( on_stop_search ), data ); g_signal_connect(data->again_btn, "clicked", G_CALLBACK( on_search_again ), data ); gtk_entry_set_text( (GtkEntry*)data->fn_pattern_entry, "*" ); gtk_editable_select_region( (GtkEditable*)data->fn_pattern_entry, 0, -1 ); gtk_combo_box_set_active( (GtkComboBox*)data->size_lower_unit, 1 ); gtk_spin_button_set_range( (GtkSpinButton*)data->size_lower, 0, G_MAXINT ); gtk_combo_box_set_active( (GtkComboBox*)data->size_upper_unit, 2 ); gtk_spin_button_set_range( (GtkSpinButton*)data->size_upper, 0, G_MAXINT ); gtk_combo_box_set_active( (GtkComboBox*)data->date_limit, 0 ); g_signal_connect( data->win, "delete-event", G_CALLBACK(gtk_widget_destroy), NULL ); pcmanfm_ref(); g_signal_connect( data->win, "destroy", G_CALLBACK(pcmanfm_unref), NULL ); int width = xset_get_int( "main_search", "x" ); int height = xset_get_int( "main_search", "y" ); if ( width && height ) gtk_window_set_default_size( GTK_WINDOW( data->win ), width, height ); gtk_widget_show( data->win ); }
static void mate_password_dialog_init (MatePasswordDialog *password_dialog) { MatePasswordDialogDetails *priv; GtkDialog *dialog = GTK_DIALOG (password_dialog); GtkWindow *window = GTK_WINDOW (password_dialog); GtkWidget *hbox, *main_vbox, *vbox, *icon; GSList *group; priv = password_dialog->details = MATE_PASSWORD_DIALOG_GET_PRIVATE (password_dialog); priv->show_username = TRUE; priv->show_password = TRUE; /* Set the dialog up with HIG properties */ gtk_dialog_set_has_separator (dialog, FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */ gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5); gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6); gtk_window_set_resizable (window, FALSE); gtk_window_set_icon_name (window, GTK_STOCK_DIALOG_AUTHENTICATION); gtk_dialog_add_buttons (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Co_nnect"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); /* Build contents */ hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, TRUE, TRUE, 0); icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); main_vbox = gtk_vbox_new (FALSE, 18); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); priv->message_label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (priv->message_label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (priv->message_label), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (priv->message_label), FALSE, FALSE, 0); gtk_widget_set_no_show_all (priv->message_label, TRUE); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); /* the radio buttons for anonymous login */ priv->radio_vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), priv->radio_vbox, FALSE, FALSE, 0); gtk_widget_set_no_show_all (priv->radio_vbox, TRUE); priv->connect_with_no_userpass_button = gtk_radio_button_new_with_mnemonic (NULL, _("Connect _anonymously")); group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON (priv->connect_with_no_userpass_button)); priv->connect_with_userpass_button = gtk_radio_button_new_with_mnemonic ( group, _("Connect as u_ser:")); g_signal_connect (priv->connect_with_no_userpass_button, "toggled", G_CALLBACK (userpass_radio_button_toggled), password_dialog); g_signal_connect (priv->connect_with_userpass_button, "toggled", G_CALLBACK (userpass_radio_button_toggled), password_dialog); gtk_box_pack_start (GTK_BOX (priv->radio_vbox), priv->connect_with_no_userpass_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->radio_vbox), priv->connect_with_userpass_button, FALSE, FALSE, 0); gtk_widget_show (priv->connect_with_no_userpass_button); gtk_widget_show (priv->connect_with_userpass_button); /* The table that holds the entries */ priv->table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); gtk_box_pack_start (GTK_BOX (vbox), priv->table_alignment, FALSE, FALSE, 0); priv->table = gtk_table_new (3, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (priv->table), 12); gtk_table_set_row_spacings (GTK_TABLE (priv->table), 6); gtk_container_add (GTK_CONTAINER (priv->table_alignment), priv->table); priv->username_entry = g_object_ref_sink (gtk_entry_new ()); priv->domain_entry = g_object_ref_sink (gtk_entry_new ()); priv->password_entry = g_object_ref_sink (gtk_entry_new ()); gtk_entry_set_visibility (GTK_ENTRY (priv->password_entry), FALSE); priv->new_password_entry = g_object_ref_sink (gtk_entry_new ()); gtk_entry_set_visibility (GTK_ENTRY (priv->new_password_entry), FALSE); priv->confirm_new_password_entry = g_object_ref_sink (gtk_entry_new ()); gtk_entry_set_visibility (GTK_ENTRY (priv->confirm_new_password_entry), FALSE); g_signal_connect (priv->username_entry, "activate", G_CALLBACK (username_entry_activate), password_dialog); g_signal_connect (priv->domain_entry, "activate", G_CALLBACK (domain_entry_activate), password_dialog); g_signal_connect (priv->password_entry, "activate", G_CALLBACK (password_entry_activate), password_dialog); g_signal_connect (priv->new_password_entry, "activate", G_CALLBACK (new_password_entry_activate), password_dialog); g_signal_connect_swapped (priv->confirm_new_password_entry, "activate", G_CALLBACK (gtk_window_activate_default), password_dialog); g_signal_connect (priv->new_password_entry, "changed", G_CALLBACK (new_password_entries_changed), password_dialog); g_signal_connect (priv->confirm_new_password_entry, "changed", G_CALLBACK (new_password_entries_changed), password_dialog); priv->quality_meter = g_object_ref_sink (gtk_progress_bar_new ()); update_entries_table (password_dialog); gtk_widget_show_all (hbox); priv->remember_box = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), priv->remember_box, FALSE, FALSE, 0); priv->remember_buttons[0] = gtk_radio_button_new_with_mnemonic (NULL, _("_Forget password immediately")); g_signal_connect (priv->remember_buttons[0], "toggled", G_CALLBACK (remember_button_toggled), password_dialog); priv->remember_buttons[1] = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (priv->remember_buttons[0]), _("_Remember password until you logout")); g_signal_connect (priv->remember_buttons[1], "toggled", G_CALLBACK (remember_button_toggled), password_dialog); priv->remember_buttons[2] = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (priv->remember_buttons[0]), _("_Remember forever")); g_signal_connect (priv->remember_buttons[2], "toggled", G_CALLBACK (remember_button_toggled), password_dialog); gtk_box_pack_start (GTK_BOX (priv->remember_box), priv->remember_buttons[0], FALSE, FALSE, 0); gtk_widget_show (priv->remember_buttons[0]); gtk_box_pack_start (GTK_BOX (priv->remember_box), priv->remember_buttons[1], FALSE, FALSE, 0); gtk_widget_show (priv->remember_buttons[1]); gtk_box_pack_start (GTK_BOX (priv->remember_box), priv->remember_buttons[2], FALSE, FALSE, 0); gtk_widget_show (priv->remember_buttons[2]); }
static GtkDialog * pgd_demo_get_auth_dialog (GFile *uri_file) { GtkDialog *dialog; GtkWidget *content_area, *action_area; GtkWidget *entry_container; GtkWidget *password_entry; GtkWidget *hbox, *main_vbox, *vbox, *icon; GtkWidget *table; GtkWidget *label; gchar *format, *markup, *file_name; dialog = GTK_DIALOG (gtk_dialog_new ()); content_area = gtk_dialog_get_content_area (dialog); action_area = gtk_dialog_get_action_area (dialog); /* Set the dialog up with HIG properties */ gtk_dialog_set_has_separator (dialog, FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (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), 6); gtk_window_set_title (GTK_WINDOW (dialog), "Enter password"); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_dialog_add_buttons (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, "_Unlock Document", GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); gtk_dialog_set_alternative_button_order (dialog, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); /* Build contents */ hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); gtk_widget_show (icon); main_vbox = gtk_vbox_new (FALSE, 18); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); gtk_widget_show (main_vbox); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); file_name = g_file_get_basename (uri_file); format = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s", "Password required", "The document “%s” is locked and requires a password before it can be opened."); markup = g_markup_printf_escaped (format, file_name); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (format); g_free (markup); g_free (file_name); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); /* The table that holds the entries */ entry_container = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); gtk_alignment_set_padding (GTK_ALIGNMENT (entry_container), 0, 0, 0, 0); gtk_box_pack_start (GTK_BOX (vbox), entry_container, FALSE, FALSE, 0); gtk_widget_show (entry_container); table = gtk_table_new (1, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (entry_container), table); gtk_widget_show (table); label = gtk_label_new_with_mnemonic ("_Password:"******"changed", G_CALLBACK (pgd_demo_auth_dialog_entry_changed), dialog); g_signal_connect (password_entry, "activate", G_CALLBACK (pgd_demo_auth_dialog_entry_activated), dialog); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (label); gtk_table_attach_defaults (GTK_TABLE (table), password_entry, 1, 2, 0, 1); gtk_widget_show (password_entry); gtk_label_set_mnemonic_widget (GTK_LABEL (label), password_entry); return dialog; }
search_dialog * create_search_dialog (GtkWindow *parent, gchar *proxy_host, gint proxy_port) { GtkWidget *vbox, *label, *button, *hbox, *scroll, *frame; GtkTreeViewColumn *column; GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); search_dialog *dialog; dialog = g_new0(search_dialog, 1); dialog->proxy_host = proxy_host; dialog->proxy_port = proxy_port; if (!dialog) return NULL; dialog->dialog = gtk_dialog_new_with_buttons (_("Search weather location code"), parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); vbox = gtk_vbox_new(FALSE, BORDER); gtk_window_set_icon_name (GTK_WINDOW (dialog->dialog), GTK_STOCK_FIND); label = gtk_label_new(_("Enter a city name or zip code:")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); dialog->search_entry = gtk_entry_new(); button = gtk_button_new_from_stock(GTK_STOCK_FIND); hbox = gtk_hbox_new(FALSE, BORDER); gtk_box_pack_start(GTK_BOX(hbox), dialog->search_entry, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); /* list */ dialog->result_mdl = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); dialog->result_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->result_mdl)); column = gtk_tree_view_column_new_with_attributes(_("Results"), renderer, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(dialog->result_list), column); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(scroll), dialog->result_list); frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(frame), scroll); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog->dialog)->vbox), vbox, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); g_signal_connect(button, "clicked", G_CALLBACK(search_cb), dialog); gtk_widget_set_size_request(dialog->dialog, 350, 250); return dialog; }
/*********************************************************************** * Create * ***********************************************************************/ GtkWidget *widget_window_create( AttributeSet *Attr, tag_attr *attr, gint Type) { gchar *value; GError *error = NULL; GList *accel_group = NULL; GList *element; gint border_width; GtkWidget *widget; stackelement s; #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Entering.\n", __func__); #endif /* Create the window widget */ widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* Set a default window title */ attributeset_set_if_unset(Attr, ATTR_LABEL, PACKAGE); gtk_window_set_title(GTK_WINDOW(widget), attributeset_get_first(&element, Attr, ATTR_LABEL)); /* Set a default title bar theme icon */ gtk_window_set_icon_name(GTK_WINDOW(widget), PACKAGE); /* If requested set a title bar image by filename */ if (attr) { if ((value = get_tag_attribute(attr, "image-name"))) gtk_window_set_icon_from_file(GTK_WINDOW(widget), find_pixmap(value), &error); } /* Set a default border width */ border_width = 5; if (attr && (value = get_tag_attribute(attr, "margin"))) /* Deprecated */ border_width = atoi(value); gtk_container_set_border_width(GTK_CONTAINER(widget), border_width); /* If we have geometry given in the command line, we set that */ if (have_geometry_dxdy) gtk_widget_set_usize(widget, geometry_dx, geometry_dy); if (have_geometry_xy) gtk_widget_set_uposition(widget, geometry_x, geometry_y); if (option_centering) gtk_window_set_position(GTK_WINDOW(widget), GTK_WIN_POS_CENTER_ALWAYS); /* Pop the widgets that the window will contain and add them */ s = pop(); gtk_container_add(GTK_CONTAINER(widget), s.widgets[0]); /* Thunor: Each menu created will have an accelerator group * for its menuitems which will require adding to the window */ if (accel_groups) { accel_group = g_list_first(accel_groups); while (accel_group) { gtk_window_add_accel_group(GTK_WINDOW(widget), GTK_ACCEL_GROUP(accel_group->data)); #ifdef DEBUG fprintf(stderr, "%s: Adding accel_group=%p to window\n", __func__, accel_group->data); #endif accel_group = accel_group->next; } g_list_free(accel_groups); accel_groups = NULL; } #ifdef DEBUG_TRANSITS fprintf(stderr, "%s(): Exiting.\n", __func__); #endif return widget; }
/** * @param ddisp The diagram display object that a window is created for * @param width Diagram widgth * @param height Diagram Height * @param title Window title * @param use_mbar Flag to indicate whether to add a menubar to the window */ void create_display_shell(DDisplay *ddisp, int width, int height, char *title, int use_mbar) { GtkWidget *table, *widget; GtkWidget *status_hbox; GtkWidget *root_vbox = NULL; GtkWidget *zoom_hbox, *zoom_label; int s_width, s_height; if (app_is_interactive() && is_integrated_ui()) { use_integrated_ui_for_display_shell(ddisp, title); return; } ddisp->is_standalone_window = TRUE; ddisp->container = NULL; s_width = gdk_screen_width (); s_height = gdk_screen_height (); if (width > s_width) width = s_width; if (height > s_height) height = s_height; /* The toplevel shell */ ddisp->shell = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (ddisp->shell), title); gtk_window_set_role (GTK_WINDOW (ddisp->shell), "diagram_window"); gtk_window_set_icon_name (GTK_WINDOW (ddisp->shell), "dia"); gtk_window_set_default_size(GTK_WINDOW (ddisp->shell), width, height); /* set_icon_name needs registered theme icons, not always available: provide fallback */ if (!gtk_window_get_icon (GTK_WINDOW (ddisp->shell))) { static GdkPixbuf *pixbuf = NULL; if (!pixbuf) pixbuf = gdk_pixbuf_new_from_inline(-1, dia_diagram_icon, FALSE, NULL); if (pixbuf) gtk_window_set_icon (GTK_WINDOW (ddisp->shell), pixbuf); } g_object_set_data (G_OBJECT (ddisp->shell), "user_data", (gpointer) ddisp); _ddisplay_setup_events (ddisp, ddisp->shell); /* following two not shared with integrated UI */ g_signal_connect (G_OBJECT (ddisp->shell), "delete_event", G_CALLBACK (ddisplay_delete), ddisp); g_signal_connect (G_OBJECT (ddisp->shell), "destroy", G_CALLBACK (ddisplay_destroy), ddisp); /* the table containing all widgets */ table = gtk_table_new (4, 3, FALSE); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_col_spacing (GTK_TABLE (table), 1, 2); gtk_table_set_row_spacing (GTK_TABLE (table), 0, 1); gtk_table_set_row_spacing (GTK_TABLE (table), 1, 2); gtk_container_set_border_width (GTK_CONTAINER (table), 2); if (use_mbar) { root_vbox = gtk_vbox_new (FALSE, 1); gtk_container_add (GTK_CONTAINER (ddisp->shell), root_vbox); gtk_box_pack_end (GTK_BOX (root_vbox), table, TRUE, TRUE, 0); } else { gtk_container_add (GTK_CONTAINER (ddisp->shell), table); } /* scrollbars, rulers, canvas, menu popup button */ if (!use_mbar) { ddisp->origin = gtk_button_new(); #if GTK_CHECK_VERSION(2,18,0) gtk_widget_set_can_focus (ddisp->origin, FALSE); #else GTK_WIDGET_UNSET_FLAGS(ddisp->origin, GTK_CAN_FOCUS); #endif widget = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_OUT); gtk_container_add(GTK_CONTAINER(ddisp->origin), widget); gtk_widget_set_tooltip_text(widget, _("Diagram menu.")); gtk_widget_show(widget); g_signal_connect(G_OBJECT(ddisp->origin), "button_press_event", G_CALLBACK(origin_button_press), ddisp); } else { ddisp->origin = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (ddisp->origin), GTK_SHADOW_OUT); } _ddisplay_setup_rulers (ddisp, ddisp->shell, table); _ddisplay_setup_scrollbars (ddisp, table, width, height); _ddisplay_setup_navigation (ddisp, table); ddisp->canvas = create_canvas (ddisp); /* pack all remaining widgets */ gtk_table_attach (GTK_TABLE (table), ddisp->origin, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), ddisp->canvas, 1, 2, 1, 2, GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0); /* TODO rob use per window accel */ ddisp->accel_group = menus_get_display_accels (); gtk_window_add_accel_group(GTK_WINDOW(ddisp->shell), ddisp->accel_group); if (use_mbar) { ddisp->menu_bar = menus_create_display_menubar (&ddisp->ui_manager, &ddisp->actions); g_assert (ddisp->menu_bar); gtk_box_pack_start (GTK_BOX (root_vbox), ddisp->menu_bar, FALSE, TRUE, 0); } /* the statusbars */ status_hbox = gtk_hbox_new (FALSE, 2); /* Zoom status pseudo-optionmenu */ ddisp->zoom_status = create_zoom_widget(ddisp); zoom_hbox = gtk_hbox_new(FALSE, 0); zoom_label = gtk_label_new(_("Zoom")); gtk_box_pack_start (GTK_BOX(zoom_hbox), zoom_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(zoom_hbox), ddisp->zoom_status, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (status_hbox), zoom_hbox, FALSE, FALSE, 0); /* Grid on/off button */ ddisp->grid_status = dia_toggle_button_new_with_icons(dia_on_grid_icon, dia_off_grid_icon); g_signal_connect(G_OBJECT(ddisp->grid_status), "toggled", G_CALLBACK (grid_toggle_snap), ddisp); gtk_widget_set_tooltip_text(ddisp->grid_status, _("Toggles snap-to-grid for this window.")); gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->grid_status, FALSE, FALSE, 0); ddisp->mainpoint_status = dia_toggle_button_new_with_icons(dia_mainpoints_on_icon, dia_mainpoints_off_icon); g_signal_connect(G_OBJECT(ddisp->mainpoint_status), "toggled", G_CALLBACK (interface_toggle_mainpoint_magnetism), ddisp); gtk_widget_set_tooltip_text(ddisp->mainpoint_status, _("Toggles object snapping for this window.")); gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->mainpoint_status, FALSE, FALSE, 0); /* Statusbar */ ddisp->modified_status = gtk_statusbar_new (); gtk_box_pack_start (GTK_BOX (status_hbox), ddisp->modified_status, TRUE, TRUE, 0); gtk_table_attach (GTK_TABLE (table), status_hbox, 0, 3, 3, 4, GTK_FILL, GTK_FILL, 0, 0); display_rulers_show (ddisp); gtk_widget_show (ddisp->zoom_status); gtk_widget_show (zoom_hbox); gtk_widget_show (zoom_label); gtk_widget_show (ddisp->grid_status); gtk_widget_show (ddisp->mainpoint_status); gtk_widget_show (ddisp->modified_status); gtk_widget_show (status_hbox); gtk_widget_show (table); if (use_mbar) { gtk_widget_show (ddisp->menu_bar); gtk_widget_show (root_vbox); } gtk_widget_show (ddisp->shell); /* before showing up, checking canvas's REAL size */ if (use_mbar && ddisp->hrule->allocation.width > width) { /* The menubar is not shrinkable, so the shell will have at least * the menubar's width. If the diagram's requested width is smaller, * the canvas will be enlarged to fit the place. In this case, we * need to adjust the horizontal scrollbar according to the size * that will be allocated, which the same as the hrule got. */ width = ddisp->hrule->allocation.width; gtk_adjustment_set_upper (ddisp->hsbdata, width); gtk_adjustment_set_page_increment (ddisp->hsbdata, (width - 1) / 4); gtk_adjustment_set_page_size (ddisp->hsbdata, width - 1); gtk_adjustment_changed (GTK_ADJUSTMENT(ddisp->hsbdata)); } gtk_widget_show (ddisp->canvas); /* set the focus to the canvas area */ gtk_widget_grab_focus (ddisp->canvas); }
static GtkWidget *create_dialog(void) { GtkWidget *dialog; GtkWidget *header_image; GtkWidget *header_label; GtkWidget *label_info; GtkWidget *codename_label; GtkWidget *builddate_label; GtkWidget *url_button; GtkWidget *cop_label; GtkWidget *label; GtkWidget *license_textview; GtkWidget *notebook; GtkWidget *box; GtkWidget *credits_scrollwin; GtkWidget *table; GtkWidget *license_scrollwin; GtkWidget *info_box; GtkWidget *header_hbox; GtkWidget *header_eventbox; GtkTextBuffer* tb; gchar *license_text = NULL; gchar buffer[512]; gchar buffer2[128]; guint i, row = 0; gchar *build_date; dialog = gtk_dialog_new(); /* configure dialog */ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(main_widgets.window)); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_title(GTK_WINDOW(dialog), _("About Geany")); gtk_window_set_icon_name(GTK_WINDOW(dialog), "geany"); gtk_widget_set_name(dialog, "GeanyDialog"); gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); g_signal_connect(dialog, "key-press-event", G_CALLBACK(gb_on_key_pressed), NULL); /* create header */ header_eventbox = gtk_event_box_new(); gtk_widget_show(header_eventbox); header_hbox = gtk_hbox_new(FALSE, 12); gtk_container_set_border_width(GTK_CONTAINER(header_hbox), 4); gtk_widget_show(header_hbox); gtk_container_add(GTK_CONTAINER(header_eventbox), header_hbox); header_image = gtk_image_new_from_icon_name("geany", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start(GTK_BOX(header_hbox), header_image, FALSE, FALSE, 0); header_label = gtk_label_new(NULL); gtk_label_set_use_markup(GTK_LABEL(header_label), TRUE); /* print the subversion revision generated by ./configure if it is available */ g_snprintf(buffer, sizeof(buffer), HEADER, main_get_version_string()); gtk_label_set_markup(GTK_LABEL(header_label), buffer); gtk_widget_show(header_label); gtk_box_pack_start(GTK_BOX(header_hbox), header_label, FALSE, FALSE, 0); header_eventbox_style_set(header_eventbox); header_label_style_set(header_label); g_signal_connect_after(header_eventbox, "style-set", G_CALLBACK(header_eventbox_style_set), NULL); g_signal_connect_after(header_label, "style-set", G_CALLBACK(header_label_style_set), NULL); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), header_eventbox, FALSE, FALSE, 0); /* create notebook */ notebook = gtk_notebook_new(); gtk_widget_show(notebook); gtk_container_set_border_width(GTK_CONTAINER(notebook), 2); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), notebook, TRUE, TRUE, 0); /* create "Info" tab */ info_box = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(info_box), 6); gtk_widget_show(info_box); label_info = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(label_info), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(label_info), TRUE); gtk_label_set_use_markup(GTK_LABEL(label_info), TRUE); g_snprintf(buffer, sizeof(buffer), INFO, _("A fast and lightweight IDE")); gtk_label_set_markup(GTK_LABEL(label_info), buffer); gtk_misc_set_padding(GTK_MISC(label_info), 2, 11); gtk_widget_show(label_info); gtk_box_pack_start(GTK_BOX(info_box), label_info, FALSE, FALSE, 0); /* Codename label */ codename_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(codename_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(codename_label), TRUE); gtk_label_set_use_markup(GTK_LABEL(codename_label), TRUE); gtk_label_set_markup(GTK_LABEL(codename_label), CODENAME); gtk_misc_set_padding(GTK_MISC(codename_label), 2, 8); gtk_widget_show(codename_label); gtk_box_pack_start(GTK_BOX(info_box), codename_label, FALSE, FALSE, 0); /* build date label */ builddate_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(builddate_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(builddate_label), TRUE); gtk_label_set_use_markup(GTK_LABEL(builddate_label), TRUE); build_date = utils_parse_and_format_build_date(__DATE__); g_snprintf(buffer2, sizeof(buffer2), _("(built on or after %s)"), build_date); g_free(build_date); g_snprintf(buffer, sizeof(buffer), BUILDDATE, buffer2); gtk_label_set_markup(GTK_LABEL(builddate_label), buffer); gtk_misc_set_padding(GTK_MISC(builddate_label), 2, 2); gtk_widget_show(builddate_label); gtk_box_pack_start(GTK_BOX(info_box), builddate_label, FALSE, FALSE, 0); box = gtk_hbutton_box_new(); url_button = gtk_button_new(); gtk_button_set_relief(GTK_BUTTON(url_button), GTK_RELIEF_NONE); g_signal_connect(url_button, "clicked", G_CALLBACK(homepage_clicked), (gpointer)GEANY_HOMEPAGE); label = gtk_label_new(NULL); gtk_label_set_text(GTK_LABEL(label), GEANY_HOMEPAGE); gtk_widget_show(label); gtk_container_add(GTK_CONTAINER(url_button), label); gtk_widget_show(url_button); gtk_box_pack_start(GTK_BOX(box), url_button, FALSE, FALSE, 0); gtk_widget_show(box); gtk_box_pack_start(GTK_BOX(info_box), box, FALSE, FALSE, 10); /* copyright label */ cop_label = gtk_label_new(NULL); gtk_label_set_justify(GTK_LABEL(cop_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable(GTK_LABEL(cop_label), FALSE); gtk_label_set_use_markup(GTK_LABEL(cop_label), TRUE); gtk_label_set_markup(GTK_LABEL(cop_label), COPYRIGHT); gtk_misc_set_padding(GTK_MISC(cop_label), 2, 10); gtk_widget_show(cop_label); gtk_box_pack_start(GTK_BOX(info_box), cop_label, FALSE, FALSE, 0); /*gtk_container_add(GTK_CONTAINER(info_box), cop_label); */ label = gtk_label_new(_("Info")); gtk_widget_show(label); gtk_widget_show_all(info_box); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_box, label); /* create "Credits" tab */ credits_scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(credits_scrollwin), 6); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(credits_scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); table = gtk_table_new(23 + translators_len + prev_translators_len, 3, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 10); row = 0; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Developers")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, GTK_FILL, 0, 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Colomban Wendling - %s", _("maintainer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Nick Treleaven - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Enrico Tröger - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Matthew Brush - %s", _("developer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "Frank Lanitz - %s", _("translation maintainer")); ROW(buffer, row, 0, 0, 0, 1); row++; ROW("<[email protected]>", row, 0, 0, 0, 1); row++; ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Translators")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; for (i = 0; i < translators_len; i++) { ROW(translators[i][0], row, 0, 1, 4, 0); ROW(translators[i][1], row, 1, 0, 4, 0); row++; } ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Previous Translators")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; for (i = 0; i < prev_translators_len; i++) { ROW(prev_translators[i][0], row, 0, 1, 4, 0); ROW(prev_translators[i][1], row, 1, 0, 4, 0); row++; } ROW("", row, 0, 0, 0, 0); row++; g_snprintf(buffer, sizeof(buffer), "<span size=\"larger\" weight=\"bold\">%s</span>", _("Contributors")); label = gtk_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; g_snprintf(buffer, sizeof(buffer), _("Some of the many contributors (for a more detailed list, see the file %s):"), #ifdef G_OS_WIN32 "Thanks.txt" #else "THANKS" #endif ); label = geany_wrap_label_new(buffer); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; label = geany_wrap_label_new(contributors); gtk_table_attach(GTK_TABLE(table), label, 0, 2, row, row + 1, (GtkAttachOptions) (GTK_FILL | GTK_EXPAND), (GtkAttachOptions) (0), 0, 5); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); row++; gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(credits_scrollwin), table); gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_widget_get_parent(table)), GTK_SHADOW_NONE); gtk_widget_show_all(table); label = gtk_label_new(_("Credits")); gtk_widget_show(label); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), credits_scrollwin, label); /* create "License" tab */ license_scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(license_scrollwin), 6); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(license_scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(license_scrollwin), GTK_SHADOW_IN); license_textview = gtk_text_view_new(); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(license_textview), 2); gtk_text_view_set_right_margin(GTK_TEXT_VIEW(license_textview), 2); gtk_text_view_set_editable(GTK_TEXT_VIEW(license_textview), FALSE); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(license_textview), FALSE); gtk_widget_show(license_textview); gtk_container_add(GTK_CONTAINER(license_scrollwin), license_textview); label = gtk_label_new(_("License")); gtk_widget_show(label); g_snprintf(buffer, sizeof(buffer), "%s" G_DIR_SEPARATOR_S "GPL-2", app->datadir); g_file_get_contents(buffer, &license_text, NULL, NULL); if (license_text == NULL) { license_text = g_strdup( _("License text could not be found, please visit http://www.gnu.org/licenses/gpl-2.0.txt to view it online.")); } tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(license_textview)); gtk_text_buffer_set_text(tb, license_text, -1); g_free(license_text); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), license_scrollwin, label); gtk_widget_show_all(dialog); return dialog; }
gboolean battery_overview (GtkWidget *widget, GdkEventButton *ev, BatteryPlugin *battery) { GtkWidget *dialog, *window, *dialog_vbox; GtkSizeGroup *sg; guint i; BatteryStatus *bat; #ifndef USE_NEW_DIALOG GtkWidget *header; #endif if (ev->button != 1) return FALSE; window = g_object_get_data (G_OBJECT (battery->plugin), "overview"); if (window) gtk_widget_destroy (window); DBG ("Show Overview"); #ifdef USE_NEW_DIALOG dialog = xfce_titled_dialog_new_with_buttons (_("Battery Information"), NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("An overview of all the batteries in the system")); #else dialog = gtk_dialog_new_with_buttons (_("Battery Information"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (battery->plugin))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); #endif gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dialog), "battery"); g_object_set_data (G_OBJECT (battery->plugin), "overview", dialog); sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); dialog_vbox = GTK_DIALOG (dialog)->vbox; #ifndef USE_NEW_DIALOG header = xfce_create_header (NULL, _("Battery Information")); gtk_widget_set_size_request (GTK_BIN (header)->child, -1, 32); gtk_container_set_border_width (GTK_CONTAINER (header), BORDER); gtk_box_pack_start (GTK_BOX (dialog_vbox), header, FALSE, TRUE, 0); #endif for (i = 0; i < battery->batteries->len; ++i) { bat = g_ptr_array_index (battery->batteries, i); battery_add_overview (dialog_vbox, bat, sg); } g_signal_connect(dialog, "response", G_CALLBACK(battery_overview_response), battery); gtk_widget_show_all (dialog); return TRUE; }
static void _settings_window(USSD * ussd) { GtkSizeGroup * group; GtkListStore * model; GtkWidget * vbox; GtkWidget * hbox; GtkWidget * image; GtkWidget * widget; GtkCellRenderer * renderer; group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); ussd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(ussd->window), 4); gtk_window_set_default_size(GTK_WINDOW(ussd->window), 200, 300); #if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_icon_name(GTK_WINDOW(ussd->window), "gnome-settings"); #endif gtk_window_set_title(GTK_WINDOW(ussd->window), "USSD"); g_signal_connect(ussd->window, "delete-event", G_CALLBACK( gtk_widget_hide), NULL); #if GTK_CHECK_VERSION(3, 0, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); #else vbox = gtk_vbox_new(FALSE, 4); #endif /* operators */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new("Operator:"); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); model = gtk_list_store_new(UO_COUNT, G_TYPE_STRING, G_TYPE_STRING); ussd->operators = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model)); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ussd->operators), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ussd->operators), renderer, "text", UO_DISPLAY, NULL); g_signal_connect_swapped(ussd->operators, "changed", G_CALLBACK( _ussd_on_operators_changed), ussd); gtk_box_pack_start(GTK_BOX(hbox), ussd->operators, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* codes */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new("Code:"); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); model = gtk_list_store_new(UC_COUNT, G_TYPE_STRING, G_TYPE_STRING); ussd->codes = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model)); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ussd->codes), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ussd->codes), renderer, "text", UC_DISPLAY, NULL); gtk_box_pack_start(GTK_BOX(hbox), ussd->codes, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* send */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new(NULL); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); widget = gtk_button_new_with_label("Send request"); image = gtk_image_new_from_icon_name("mail-send", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(widget), image); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _ussd_on_settings_send), ussd); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* button box */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); #else hbox = gtk_hbutton_box_new(); #endif gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(hbox), 4); widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _ussd_on_settings_close), ussd); gtk_container_add(GTK_CONTAINER(hbox), widget); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(ussd->window), vbox); if(ussd->config != NULL) config_foreach(ussd->config, _settings_window_operators, ussd); gtk_widget_show_all(vbox); }
/** * gpk_log_startup_cb: **/ static void gpk_log_startup_cb (GtkApplication *application, gpointer user_data) { gboolean ret; GError *error = NULL; GSettings *settings; GtkEntryCompletion *completion; GtkTreeSelection *selection; GtkWidget *widget; GtkWindow *window; guint retval; client = pk_client_new (); g_object_set (client, "background", FALSE, NULL); /* get UI */ builder = gtk_builder_new (); retval = gtk_builder_add_from_file (builder, GPK_DATA "/pi-gpk-log.ui", &error); if (retval == 0) { g_warning ("failed to load ui: %s", error->message); g_error_free (error); goto out; } window = GTK_WINDOW (gtk_builder_get_object (builder, "dialog_simple")); gtk_window_set_icon_name (window, GPK_ICON_SOFTWARE_LOG); gtk_window_set_application (window, application); /* set a size, as the screen allows */ gpk_window_set_size_request (window, 1200, 1200); /* if command line arguments are set, then setup UI */ if (filter != NULL) { widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package")); gtk_entry_set_text (GTK_ENTRY(widget), filter); } widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close")); g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_close_cb), application); gtk_widget_grab_default (widget); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_refresh")); g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_refresh_cb), NULL); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_filter")); g_signal_connect (widget, "clicked", G_CALLBACK (gpk_log_button_filter_cb), NULL); /* hit enter in the search box for filter */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package")); g_signal_connect (widget, "activate", G_CALLBACK (gpk_log_button_filter_cb), NULL); /* autocompletion can be turned off as it's slow */ settings = g_settings_new (GPK_SETTINGS_SCHEMA); ret = g_settings_get_boolean (settings, GPK_SETTINGS_AUTOCOMPLETE); if (ret) { /* create the completion object */ completion = gpk_package_entry_completion_new (); widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry_package")); gtk_entry_set_completion (GTK_ENTRY (widget), completion); g_object_unref (completion); } else { /* use search as you type */ g_signal_connect (widget, "key-release-event", G_CALLBACK (gpk_log_entry_filter_cb), NULL); } g_object_unref (settings); /* create list stores */ list_store = gtk_list_store_new (GPK_LOG_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); /* create transaction_id tree view */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_simple")); gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (list_store)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); g_signal_connect (selection, "changed", G_CALLBACK (gpk_log_treeview_clicked_cb), NULL); /* add columns to the tree view */ pk_treeview_add_general_columns (GTK_TREE_VIEW (widget)); gtk_tree_view_columns_autosize (GTK_TREE_VIEW (widget)); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), GPK_LOG_COLUMN_TIMESPEC, GTK_SORT_DESCENDING); /* show */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_simple")); gtk_widget_show (widget); /* set the parent window if it is specified */ if (xid != 0) { g_debug ("Setting xid %i", xid); gpk_window_set_parent_xid (GTK_WINDOW (widget), xid); } /* get the update list */ gpk_log_refresh (); out: g_object_unref (list_store); g_object_unref (client); g_free (transaction_id); g_free (filter); if (transactions != NULL) g_ptr_array_unref (transactions); }
static GtkWidget * gsm_get_dialog (GsmDialogLogoutType type, GdkScreen *screen, guint32 activate_time) { GsmLogoutDialog *logout_dialog; GtkWidget *dialog_image; GtkWidget *hbox; const char *primary_text; const char *icon_name; if (current_dialog != NULL) { gtk_widget_destroy (GTK_WIDGET (current_dialog)); } logout_dialog = g_object_new (GSM_TYPE_LOGOUT_DIALOG, NULL); current_dialog = logout_dialog; gtk_window_set_title (GTK_WINDOW (logout_dialog), ""); logout_dialog->priv->type = type; icon_name = NULL; primary_text = NULL; switch (type) { case GSM_DIALOG_LOGOUT_TYPE_LOGOUT: icon_name = GSM_ICON_LOGOUT; primary_text = _("Log out of this system now?"); logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_LOGOUT; if (gsm_logout_supports_switch_user (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Switch User"), GSM_LOGOUT_RESPONSE_SWITCH_USER); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Log Out"), GSM_LOGOUT_RESPONSE_LOGOUT); break; case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: icon_name = GSM_ICON_SHUTDOWN; primary_text = _("Shut down this system now?"); logout_dialog->priv->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN; if (gsm_logout_supports_system_suspend (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("S_uspend"), GSM_LOGOUT_RESPONSE_SLEEP); } if (gsm_logout_supports_system_hibernate (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Hibernate"), GSM_LOGOUT_RESPONSE_HIBERNATE); } if (gsm_logout_supports_reboot (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Restart"), GSM_LOGOUT_RESPONSE_REBOOT); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); if (gsm_logout_supports_shutdown (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Shut Down"), GSM_LOGOUT_RESPONSE_SHUTDOWN); } break; default: g_assert_not_reached (); } dialog_image = gtk_message_dialog_get_image (GTK_MESSAGE_DIALOG (logout_dialog)); #if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #else hbox = gtk_hbox_new (FALSE, 0); #endif logout_dialog->priv->progressbar = gtk_progress_bar_new (); #if GTK_CHECK_VERSION (3, 0, 0) gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), TRUE); #endif gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), 1.0); gtk_box_pack_start (GTK_BOX (hbox), logout_dialog->priv->progressbar, TRUE, TRUE, 12); gtk_widget_show_all (hbox); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), hbox); gtk_image_set_from_icon_name (GTK_IMAGE (dialog_image), icon_name, GTK_ICON_SIZE_DIALOG); gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name); gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text); gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog), logout_dialog->priv->default_response); gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen); return GTK_WIDGET (logout_dialog); }
static void polkit_mate_authentication_dialog_constructed (GObject *object) { PolkitMateAuthenticationDialog *dialog; GtkWidget *hbox; GtkWidget *main_vbox; GtkWidget *vbox; GtkWidget *table_alignment; GtkWidget *table; GtkWidget *details_expander; GtkWidget *details_vbox; GtkWidget *label; GtkWidget *image; GtkWidget *content_area; GtkWidget *action_area; gboolean have_user_combobox; gchar *s; guint rows; dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object); if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL) G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object); have_user_combobox = FALSE; dialog->priv->cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Authenticate"), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); #if !GTK_CHECK_VERSION(3, 0, 0) gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); #endif gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (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), 6); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION); hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); image = get_image (dialog); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); main_vbox = gtk_vbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0); /* main message */ label = gtk_label_new (NULL); s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message); gtk_label_set_markup (GTK_LABEL (label), s); g_free (s); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); /* secondary message */ label = gtk_label_new (NULL); if (g_strv_length (dialog->priv->users) > 1) { gtk_label_set_markup (GTK_LABEL (label), _("An application is attempting to perform an action that requires privileges. " "Authentication as one of the users below is required to perform this action.")); } else { if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0) { gtk_label_set_markup (GTK_LABEL (label), _("An application is attempting to perform an action that requires privileges. " "Authentication is required to perform this action.")); } else { gtk_label_set_markup (GTK_LABEL (label), _("An application is attempting to perform an action that requires privileges. " "Authentication as the super user is required to perform this action.")); } } gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0); /* user combobox */ if (g_strv_length (dialog->priv->users) > 1) { dialog->priv->user_combobox = gtk_combo_box_new (); gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0); create_user_combobox (dialog); have_user_combobox = TRUE; } else { dialog->priv->selected_user = g_strdup (dialog->priv->users[0]); } /* password entry */ vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); gtk_box_pack_start (GTK_BOX (vbox), table_alignment, FALSE, FALSE, 0); table = gtk_table_new (1, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (table_alignment), table); dialog->priv->password_entry = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE); dialog->priv->prompt_label = add_row (table, 0, _("_Password:"******"activate", G_CALLBACK (gtk_window_activate_default), dialog); dialog->priv->table_alignment = table_alignment; /* initially never show the password entry stuff; we'll toggle it on/off so it's * only shown when prompting for a password */ gtk_widget_set_no_show_all (dialog->priv->table_alignment, TRUE); /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */ label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); dialog->priv->info_label = label; /* Details */ details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>")); gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE); gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0); details_vbox = gtk_vbox_new (FALSE, 10); gtk_container_add (GTK_CONTAINER (details_expander), details_vbox); table_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0); gtk_box_pack_start (GTK_BOX (details_vbox), table_alignment, FALSE, FALSE, 0); table = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_container_add (GTK_CONTAINER (table_alignment), table); /* TODO: sort keys? */ rows = 0; if (dialog->priv->details != NULL) { guint n; gchar **keys; keys = polkit_details_get_keys (dialog->priv->details); for (n = 0; keys[n] != NULL; n++) { const gchar *key = keys[n]; const gchar *value; value = polkit_details_lookup (dialog->priv->details, key); label = gtk_label_new (NULL); s = g_strdup_printf ("<small>%s</small>", value); gtk_label_set_markup (GTK_LABEL (label), s); g_free (s); gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); s = g_strdup_printf ("<small><b>%s:</b></small>", key); add_row (table, rows, s, label); g_free (s); rows++; } g_strfreev (keys); } /* --- */ label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>", dialog->priv->action_id, dialog->priv->action_id); gtk_label_set_markup (GTK_LABEL (label), s); g_free (s); gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); add_row (table, rows++, _("<small><b>Action:</b></small>"), label); g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL); s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id); gtk_widget_set_tooltip_markup (label, s); g_free (s); /* --- */ label = gtk_label_new (NULL); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>", dialog->priv->vendor_url, dialog->priv->vendor); gtk_label_set_markup (GTK_LABEL (label), s); g_free (s); gtk_misc_set_alignment (GTK_MISC (label), 0, 1.0); add_row (table, rows++, _("<small><b>Vendor:</b></small>"), label); s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url); gtk_widget_set_tooltip_markup (label, s); g_free (s); if (have_user_combobox) { /* ... and make the password entry and "Authenticate" button insensitive */ gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE); gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE); gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE); } else { } gtk_widget_realize (GTK_WIDGET (dialog)); }
/** * changed_component_dialog: * @parent: Parent window for the dialog. * @comp: A calendar component * @deleted: Whether the object is being deleted or updated * @changed: Whether or not the user has made changes * * Pops up a dialog box asking the user whether changes made (if any) * should be thrown away because the item has been updated elsewhere * * Return value: TRUE if the user clicked Yes, FALSE otherwise. **/ gboolean changed_component_dialog (GtkWindow *parent, ECalComponent *comp, gboolean deleted, gboolean changed) { GtkWidget *dialog; ECalComponentVType vtype; gchar *str; gint response; vtype = e_cal_component_get_vtype (comp); if (deleted) { switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("This event has been deleted."); break; case E_CAL_COMPONENT_TODO: str = _("This task has been deleted."); break; case E_CAL_COMPONENT_JOURNAL: str = _("This memo has been deleted."); break; default: g_message ( "changed_component_dialog(): " "Cannot handle object of type %d", vtype); return FALSE; } if (changed) str = g_strdup_printf (_("%s You have made changes. Forget those changes and close the editor?"), str); else str = g_strdup_printf (_("%s You have made no changes, close the editor?"), str); } else { switch (vtype) { case E_CAL_COMPONENT_EVENT: str = _("This event has been changed."); break; case E_CAL_COMPONENT_TODO: str = _("This task has been changed."); break; case E_CAL_COMPONENT_JOURNAL: str = _("This memo has been changed."); break; default: g_message ( "changed_component_dialog(): " "Cannot handle object of type %d", vtype); return FALSE; } if (changed) str = g_strdup_printf (_("%s You have made changes. Forget those changes and update the editor?"), str); else str = g_strdup_printf (_("%s You have made no changes, update the editor?"), str); } dialog = gtk_message_dialog_new ( parent, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", str); gtk_window_set_icon_name (GTK_WINDOW (dialog), "x-office-calendar"); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_YES) return TRUE; else return FALSE; }
GtkWidget * create_dialog (void) { GtkWidget *dlg; GtkWidget *hbox, *vbox, *hbox2, *bbox; GtkWidget *image; GtkWidget *text; GtkWidget *main_widget = NULL; GtkWidget *topb = NULL; /* create dialog window */ dlg = gtk_dialog_new (); if (options.data.splash) gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); else gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_title (GTK_WINDOW (dlg), options.data.dialog_title); gtk_widget_set_name (dlg, "yad-dialog-window"); #ifndef G_OS_WIN32 if (options.parent) { gdk_window_set_transient_for (gtk_widget_get_window (dlg), gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), options.parent)); } #endif if (options.data.no_escape) g_signal_connect (G_OBJECT (dlg), "close", G_CALLBACK (ignore_close_cb) , NULL); /* get buttons container */ bbox = gtk_dialog_get_action_area (GTK_DIALOG (dlg)); /* set window icon */ if (options.data.window_icon) { if (g_file_test (options.data.window_icon, G_FILE_TEST_EXISTS)) gtk_window_set_icon_from_file (GTK_WINDOW (dlg), options.data.window_icon, NULL); else gtk_window_set_icon_name (GTK_WINDOW (dlg), options.data.window_icon); } /* set window borders */ if (options.data.borders == -1) options.data.borders = (gint) gtk_container_get_border_width (GTK_CONTAINER (dlg)); gtk_container_set_border_width (GTK_CONTAINER (dlg), (guint) options.data.borders); /* set window size and position */ if (!options.data.geometry && !options.data.maximized && !options.data.fullscreen) { gtk_window_set_default_size (GTK_WINDOW (dlg), options.data.width, options.data.height); if (options.data.center) gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); else if (options.data.mouse) gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); } /* set window behavior */ if (options.data.sticky) gtk_window_stick (GTK_WINDOW (dlg)); gtk_window_set_keep_above (GTK_WINDOW (dlg), options.data.ontop); gtk_window_set_decorated (GTK_WINDOW (dlg), !options.data.undecorated); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), options.data.skip_taskbar); gtk_window_set_skip_pager_hint (GTK_WINDOW (dlg), options.data.skip_taskbar); /* create timeout indicator widget */ if (options.data.timeout) { if (G_LIKELY (options.data.to_indicator) && g_ascii_strcasecmp (options.data.to_indicator, "none")) { topb = gtk_progress_bar_new (); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (topb), 1.0); gtk_widget_set_name (topb, "yad-timeout-indicator"); } } /* add top label widgets */ #if !GTK_CHECK_VERSION(3,0,0) hbox = hbox2 = gtk_hbox_new (FALSE, 0); #else hbox = hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #endif gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), hbox, TRUE, TRUE, 5); #if !GTK_CHECK_VERSION(3,0,0) vbox = gtk_vbox_new (FALSE, 0); #else vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #endif /* add timeout indicator */ if (topb) { if (g_ascii_strcasecmp (options.data.to_indicator, "top") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_LEFT_TO_RIGHT); #endif gtk_box_pack_start (GTK_BOX (vbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "bottom") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_LEFT_TO_RIGHT); #endif gtk_box_pack_end (GTK_BOX (vbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "left") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_BOTTOM_TO_TOP); #endif gtk_box_pack_start (GTK_BOX (hbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "right") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_BOTTOM_TO_TOP); #endif gtk_box_pack_end (GTK_BOX (hbox), topb, FALSE, FALSE, 2); } if (settings.show_remain) { gchar *lbl = g_strdup_printf (_("%d sec"), options.data.timeout); #if GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (topb), TRUE); #endif gtk_progress_bar_set_text (GTK_PROGRESS_BAR (topb), lbl); g_free (lbl); } } /* must be after indicator! */ gtk_box_pack_end (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); if (options.data.image_on_top) { #if !GTK_CHECK_VERSION(3,0,0) hbox2 = gtk_hbox_new (FALSE, 0); #else hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #endif gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); } if (options.data.dialog_image) { GdkPixbuf *pb = NULL; pb = get_pixbuf (options.data.dialog_image, YAD_BIG_ICON); image = gtk_image_new_from_pixbuf (pb); if (pb) g_object_unref (pb); gtk_widget_set_name (image, "yad-dialog-image"); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox2), image, FALSE, FALSE, 2); } if (options.data.dialog_text) { /* for dnd's tooltip we don't need text label */ if (options.mode != YAD_MODE_DND || !options.dnd_data.tooltip) { gchar *buf = g_strcompress (options.data.dialog_text); text = gtk_label_new (NULL); if (!options.data.no_markup) gtk_label_set_markup (GTK_LABEL (text), buf); else gtk_label_set_text (GTK_LABEL (text), buf); g_free (buf); gtk_widget_set_name (text, "yad-dialog-label"); gtk_label_set_line_wrap (GTK_LABEL (text), TRUE); gtk_label_set_selectable (GTK_LABEL (text), options.data.selectable_labels); gtk_label_set_justify (GTK_LABEL (text), options.data.text_align); switch (options.data.text_align) { case GTK_JUSTIFY_LEFT: case GTK_JUSTIFY_FILL: gtk_misc_set_alignment (GTK_MISC (text), 0.0, 0.5); break; case GTK_JUSTIFY_CENTER: gtk_misc_set_alignment (GTK_MISC (text), 0.5, 0.5); break; case GTK_JUSTIFY_RIGHT: gtk_misc_set_alignment (GTK_MISC (text), 1.0, 0.5); break; } if (options.data.image_on_top) gtk_box_pack_start (GTK_BOX (hbox2), text, TRUE, TRUE, 2); else gtk_box_pack_start (GTK_BOX (vbox), text, FALSE, FALSE, 2); #if !GTK_CHECK_VERSION(3,0,0) if (!options.data.fixed) g_signal_connect (G_OBJECT (text), "size-allocate", G_CALLBACK (text_size_allocate_cb), NULL); #endif } } /* add main widget */ switch (options.mode) { case YAD_MODE_CALENDAR: main_widget = calendar_create_widget (dlg); break; case YAD_MODE_COLOR: main_widget = color_create_widget (dlg); break; case YAD_MODE_DND: dnd_init (dlg); break; case YAD_MODE_ENTRY: main_widget = entry_create_widget (dlg); break; case YAD_MODE_FILE: main_widget = file_create_widget (dlg); break; case YAD_MODE_FONT: main_widget = font_create_widget (dlg); break; case YAD_MODE_FORM: main_widget = form_create_widget (dlg); break; #ifdef HAVE_HTML case YAD_MODE_HTML: main_widget = html_create_widget (dlg); break; #endif case YAD_MODE_ICONS: main_widget = icons_create_widget (dlg); break; case YAD_MODE_LIST: main_widget = list_create_widget (dlg); break; case YAD_MODE_MULTI_PROGRESS: main_widget = multi_progress_create_widget (dlg); break; case YAD_MODE_NOTEBOOK: main_widget = notebook_create_widget (dlg); break; case YAD_MODE_PANED: main_widget = paned_create_widget (dlg); break; case YAD_MODE_PROGRESS: main_widget = progress_create_widget (dlg); break; case YAD_MODE_SCALE: main_widget = scale_create_widget (dlg); break; case YAD_MODE_TEXTINFO: main_widget = text_create_widget (dlg); break; default: ; } if (main_widget) { if (options.data.expander) { GtkWidget *exp; exp = gtk_expander_new_with_mnemonic (options.data.expander); gtk_expander_set_expanded (GTK_EXPANDER (exp), FALSE); gtk_container_add (GTK_CONTAINER (exp), main_widget); gtk_box_pack_start (GTK_BOX (vbox), exp, TRUE, TRUE, 2); } else gtk_box_pack_start (GTK_BOX (vbox), main_widget, TRUE, TRUE, 2); } /* add buttons */ if (!options.data.no_buttons) { if (options.data.buttons) { GSList *tmp = options.data.buttons; do { GtkWidget *btn; YadButton *b = (YadButton *) tmp->data; btn = gtk_button_new (); gtk_container_add (GTK_CONTAINER (btn), get_label (b->name, 2)); gtk_button_set_alignment (GTK_BUTTON (btn), 0.5, 0.5); g_object_set_data (G_OBJECT (btn), "resp", GINT_TO_POINTER (b->response)); g_signal_connect (G_OBJECT (btn), "clicked", G_CALLBACK (btn_cb), b->cmd); gtk_box_pack_start (GTK_BOX (bbox), btn, FALSE, FALSE, 0); tmp = tmp->next; } while (tmp != NULL); } else { if (options.mode == YAD_MODE_PROGRESS || options.mode == YAD_MODE_MULTI_PROGRESS) gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_CLOSE, YAD_RESPONSE_OK, NULL); else { if (gtk_alternative_dialog_button_order (NULL)) gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_OK, YAD_RESPONSE_OK, GTK_STOCK_CANCEL, YAD_RESPONSE_CANCEL, NULL); else gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_CANCEL, YAD_RESPONSE_CANCEL, GTK_STOCK_OK, YAD_RESPONSE_OK, NULL); } gtk_dialog_set_default_response (GTK_DIALOG (dlg), YAD_RESPONSE_OK); } gtk_button_box_set_layout (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), options.data.buttons_layout); } /* show widgets */ gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (dlg))); if (options.data.no_buttons) gtk_widget_hide (bbox); /* parse geometry, if given. must be after showing widget */ if (options.data.geometry && !options.data.maximized && !options.data.fullscreen) { gtk_widget_realize (dlg); gtk_window_parse_geometry (GTK_WINDOW (dlg), options.data.geometry); } gtk_widget_show (dlg); /* set maximized or fixed size after showing widget */ if (options.data.maximized) gtk_window_maximize (GTK_WINDOW (dlg)); else if (options.data.fullscreen) gtk_window_fullscreen (GTK_WINDOW (dlg)); else { gtk_window_set_resizable (GTK_WINDOW (dlg), !options.data.fixed); if (options.data.fixed) gtk_widget_set_size_request (dlg, options.data.width, options.data.height); } /* set timeout */ if (options.data.timeout) { g_timeout_add_seconds (options.data.timeout, timeout_cb, dlg); g_timeout_add_seconds (1, timeout_indicator_cb, topb); } #ifndef G_OS_WIN32 /* print xid */ if (options.print_xid) { fprintf (stderr, "0x%lX", GDK_WINDOW_XID (gtk_widget_get_window (dlg))); fflush (stderr); } #endif return dlg; }
/** * main: **/ int main (int argc, char *argv[]) { gboolean program_version = FALSE; GOptionContext *context; GtkWidget *main_window; GtkWidget *widget; PkControl *control; UniqueApp *unique_app; guint retval; guint xid = 0; GError *error = NULL; GMainLoop *loop; const GOptionEntry options[] = { { "version", '\0', 0, G_OPTION_ARG_NONE, &program_version, _("Show the program version and exit"), NULL }, { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid, /* TRANSLATORS: we can make this modal (stay on top of) another window */ _("Set the parent window to make this modal"), NULL }, { NULL} }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); if (! g_thread_supported ()) g_thread_init (NULL); dbus_g_thread_init (); g_type_init (); gtk_init (&argc, &argv); context = g_option_context_new (NULL); /* TRANSLATORS: program name, an application to set per-user policy for updates */ g_option_context_set_summary(context, _("Software Update Preferences")); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, egg_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); if (program_version) { g_print (VERSION "\n"); return 0; } /* are we already activated? */ unique_app = unique_app_new ("org.freedesktop.PackageKit.Prefs", NULL); if (unique_app_is_running (unique_app)) { egg_debug ("You have another instance running. This program will now close"); unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); goto unique_out; } g_signal_connect (unique_app, "message-received", G_CALLBACK (gpk_prefs_message_received_cb), NULL); /* get actions */ loop = g_main_loop_new (NULL, FALSE); control = pk_control_new (); g_signal_connect (control, "notify::network-state", G_CALLBACK (gpk_prefs_notify_network_state_cb), NULL); /* get UI */ builder = gtk_builder_new (); retval = gtk_builder_add_from_file (builder, GPK_DATA "/gpk-prefs.ui", &error); if (retval == 0) { egg_warning ("failed to load ui: %s", error->message); g_error_free (error); goto out_build; } main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_prefs")); /* Hide window first so that the dialogue resizes itself without redrawing */ gtk_widget_hide (main_window); gtk_window_set_icon_name (GTK_WINDOW (main_window), GPK_ICON_SOFTWARE_UPDATE_PREFS); g_signal_connect (main_window, "delete_event", G_CALLBACK (gpk_prefs_delete_event_cb), loop); widget = GTK_WIDGET (gtk_builder_get_object (builder, "checkbutton_mobile_broadband")); gpk_prefs_notify_checkbutton_setup (widget, GPK_CONF_CONNECTION_USE_MOBILE); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close")); g_signal_connect (widget, "clicked", G_CALLBACK (gpk_prefs_close_cb), loop); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help")); g_signal_connect (widget, "clicked", G_CALLBACK (gpk_prefs_help_cb), NULL); /* update the combo boxes */ gpk_prefs_update_freq_combo_setup (); gpk_prefs_upgrade_freq_combo_setup (); gpk_prefs_auto_update_combo_setup (); gtk_widget_show (main_window); /* set the parent window if it is specified */ if (xid != 0) { egg_debug ("Setting xid %i", xid); gpk_window_set_parent_xid (GTK_WINDOW (main_window), xid); } /* get some data */ pk_control_get_properties_async (control, NULL, (GAsyncReadyCallback) gpk_prefs_get_properties_cb, loop); /* wait */ g_main_loop_run (loop); out_build: g_main_loop_unref (loop); g_object_unref (control); g_object_unref (builder); unique_out: g_object_unref (unique_app); return 0; }
static void status_menu_clear_status_message_dialog_run (StatusMenu *self) { GtkTreeIter iter, liter; GSList *conf_list [3] = { NULL, NULL, NULL }; GtkWidget *dialog = NULL; GtkWidget *vbox = NULL; GtkWidget *frame = NULL; GtkWidget *tree_view = NULL; GdkPixbuf *pixbuf = NULL; GtkTreeSelection *selection = NULL; GtkListStore *list_store = NULL; GtkCellRenderer *renderer = NULL; GtkTreeViewColumn *column = NULL; GtkWidget *label = NULL; bool found = false; bool close = false; int response = 0; int i = 0; gchar *message = NULL; std::string status; // Current status status = self->priv->personal_data_settings->get_string ("long-status"); // Build the dialog dialog = gtk_dialog_new_with_buttons (_("Custom Message"), self->priv->parent, (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_DELETE, GTK_RESPONSE_APPLY, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DELETE); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, false, false, 2); label = gtk_label_new (_("Delete custom messages:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, false, false, 2); list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store)); g_object_unref (list_store); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), false); column = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "pixbuf", 0, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "text", 1, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); frame = gtk_frame_new (NULL); gtk_container_add (GTK_CONTAINER (frame), tree_view); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 2); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->list_store), &iter)) { do { gtk_tree_model_get (GTK_TREE_MODEL (self->priv->list_store), &iter, COL_MESSAGE_TYPE, &i, -1); if (i == TYPE_CUSTOM_AVAILABLE || i == TYPE_CUSTOM_AWAY || i == TYPE_CUSTOM_BUSY) { gtk_tree_model_get (GTK_TREE_MODEL (self->priv->list_store), &iter, COL_ICON, &pixbuf, COL_MESSAGE, &message, -1); gtk_list_store_append (GTK_LIST_STORE (list_store), &liter); gtk_list_store_set (GTK_LIST_STORE (list_store), &liter, COL_ICON, pixbuf, COL_MESSAGE, message, COL_MESSAGE_TYPE, i, -1); g_free (message); g_object_unref (pixbuf); } } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->priv->list_store), &iter)); } // Select the first iter selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter)) gtk_tree_selection_select_iter (selection, &iter); gtk_widget_show_all (dialog); while (!close) { response = gtk_dialog_run (GTK_DIALOG (dialog)); switch (response) { case GTK_RESPONSE_APPLY: if (gtk_tree_selection_get_selected (selection, NULL, &iter)) gtk_list_store_remove (GTK_LIST_STORE (list_store), &iter); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter)) gtk_tree_selection_select_iter (selection, &iter); else close = true; break; case GTK_RESPONSE_CLOSE: default: close = true; } } if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter)) { do { gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, 1, &message, 2, &i, -1); if (!status.empty () && status == message) found = true; conf_list[i - NUM_STATUS_TYPES - 1] = g_slist_append (conf_list[i - NUM_STATUS_TYPES - 1], g_strdup (message)); g_free (message); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store), &iter)); } for (int j = 0 ; j < 3 ; j++) { self->priv->personal_data_settings->set_slist (status_types_keys[j], conf_list[j]); g_slist_foreach (conf_list[j], (GFunc) g_free, NULL); g_slist_free (conf_list[j]); } if (!found) { // Reset current config self->priv->personal_details->set_presence_info ("available", ""); } gtk_widget_destroy (dialog); }
/** * main: **/ int main (int argc, char **argv) { CdClient *client = NULL; CdProfile *profile_tmp = NULL; const gchar *copyright; const gchar *description; const gchar *title; const gchar *lang; gboolean ret; gchar **files = NULL; CdIcc *icc = NULL; GError *error = NULL; GFile *destination = NULL; GFile *file = NULL; GOptionContext *context; GString *string = NULL; GtkResponseType response; GtkWidget *image = NULL; GtkWidget *dialog; guint retval = 1; const GOptionEntry options[] = { { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files, /* TRANSLATORS: command line option: a list of catalogs to install */ _("ICC profile to install"), NULL }, { NULL} }; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init (&argc, &argv); context = g_option_context_new ("gnome-color-manager import program"); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gcm_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* nothing sent */ if (files == NULL) { /* TRANSLATORS: nothing was specified on the command line */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("No filename specified")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); goto out; } /* load profile */ icc = cd_icc_new (); file = g_file_new_for_path (files[0]); ret = cd_icc_load_file (icc, file, CD_ICC_LOAD_FLAGS_FALLBACK_MD5, NULL, &error); if (!ret) { /* TRANSLATORS: could not read file */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Failed to open ICC profile")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); /* TRANSLATORS: parsing error */ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), _("Failed to parse file: %s"), error->message); gtk_dialog_run (GTK_DIALOG (dialog)); g_error_free (error); gtk_widget_destroy (dialog); goto out; } /* get data */ lang = g_getenv ("LANG"); description = cd_icc_get_description (icc, lang, NULL); copyright = cd_icc_get_copyright (icc, lang, NULL); /* use the same icon as the color control panel */ image = gtk_image_new_from_icon_name ("preferences-color", GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_widget_show (image); /* create message */ string = g_string_new (""); /* TRANSLATORS: message text */ g_string_append_printf (string, _("Profile description: %s"), description != NULL ? description : files[0]); /* add copyright */ if (copyright != NULL) { if (g_str_has_prefix (copyright, "Copyright ")) copyright += 10; if (g_str_has_prefix (copyright, "Copyright, ")) copyright += 11; /* TRANSLATORS: message text */ g_string_append_printf (string, "\n%s %s", _("Profile copyright:"), copyright); } /* check file does't already exist as system-wide */ client = cd_client_new (); ret = cd_client_connect_sync (client, NULL, &error); if (!ret) { g_warning ("failed to connect to colord: %s", error->message); g_error_free (error); goto out; } profile_tmp = cd_client_find_profile_by_property_sync (client, CD_PROFILE_METADATA_FILE_CHECKSUM, cd_icc_get_checksum (icc), NULL, NULL); if (profile_tmp != NULL) { ret = cd_profile_connect_sync (profile_tmp, NULL, &error); if (!ret) { g_warning ("failed to connect to profile %s: %s", cd_profile_get_object_path (profile_tmp), error->message); g_error_free (error); goto out; } /* TRANSLATORS: color profile already been installed */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, _("Color profile is already imported")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", string->str); gtk_dialog_add_button (GTK_DIALOG (dialog), _("Show Details"), GTK_RESPONSE_HELP); response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_HELP) { gcm_import_show_details (GTK_WINDOW (dialog), TRUE, cd_profile_get_id (profile_tmp)); goto try_harder; } gtk_widget_destroy (dialog); goto out; } /* get correct title */ switch (cd_icc_get_kind (icc)) { case CD_PROFILE_KIND_DISPLAY_DEVICE: /* TRANSLATORS: the profile type */ title = _("Import display color profile?"); break; case CD_PROFILE_KIND_OUTPUT_DEVICE: /* TRANSLATORS: the profile type */ title = _("Import device color profile?"); break; case CD_PROFILE_KIND_NAMED_COLOR: /* TRANSLATORS: the profile type */ title = _("Import named color profile?"); break; default: /* TRANSLATORS: the profile type */ title = _("Import color profile?"); break; } /* ask confirmation */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL, "%s", title); gtk_message_dialog_set_image (GTK_MESSAGE_DIALOG (dialog), image); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", string->str); /* TRANSLATORS: button text */ gtk_dialog_add_button (GTK_DIALOG (dialog), _("Import"), GTK_RESPONSE_OK); gtk_dialog_add_button (GTK_DIALOG (dialog), _("Show Details"), GTK_RESPONSE_HELP); try_harder: response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_HELP) { gcm_import_show_details (GTK_WINDOW (dialog), FALSE, files[0]); goto try_harder; } gtk_widget_destroy (dialog); /* not the correct response */ if (response != GTK_RESPONSE_OK) goto out; /* copy icc file to users profile path */ profile_tmp = cd_client_import_profile_sync (client, file, NULL, &error); if (profile_tmp == NULL) { /* TRANSLATORS: could not read file */ dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Failed to import file")); gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON); gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message); gtk_dialog_run (GTK_DIALOG (dialog)); g_error_free (error); gtk_widget_destroy (dialog); goto out; } out: if (file != NULL) g_object_unref (file); if (string != NULL) g_string_free (string, TRUE); if (icc != NULL) g_object_unref (icc); if (client != NULL) g_object_unref (client); if (profile_tmp != NULL) g_object_unref (profile_tmp); if (destination != NULL) g_object_unref (destination); g_strfreev (files); return retval; }
static void nautilus_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *window) { GtkWidget *dialog; /* setup UI */ nautilus_file_management_properties_size_group_create (builder, "views_label", 4); nautilus_file_management_properties_size_group_create (builder, "captions_label", 3); nautilus_file_management_properties_size_group_create (builder, "preview_label", 4); create_date_format_menu (builder); /* setup preferences */ bind_builder_bool (builder, nautilus_icon_view_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LABELS_BESIDE_ICONS_WIDGET, NAUTILUS_PREFERENCES_ICON_VIEW_LABELS_BESIDE_ICONS); bind_builder_bool (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_FOLDERS_FIRST_WIDGET, NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST); bind_builder_bool_inverted (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ALWAYS_USE_BROWSER_WIDGET, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER); bind_builder_bool (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_CONFIRM_WIDGET, NAUTILUS_PREFERENCES_CONFIRM_TRASH); bind_builder_bool (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_TRASH_DELETE_WIDGET, NAUTILUS_PREFERENCES_ENABLE_DELETE); bind_builder_bool (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SHOW_HIDDEN_WIDGET, NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET, NAUTILUS_PREFERENCES_DEFAULT_FOLDER_VIEWER, (const char **) default_view_values); bind_builder_enum (builder, nautilus_icon_view_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET, NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, (const char **) zoom_values); bind_builder_enum (builder, nautilus_list_view_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_LIST_VIEW_ZOOM_WIDGET, NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL, (const char **) zoom_values); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_SORT_ORDER_WIDGET, NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER, (const char **) sort_order_values); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_TEXT_WIDGET, NAUTILUS_PREFERENCES_SHOW_TEXT_IN_ICONS, (const char **) preview_values); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_IMAGE_WIDGET, NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS, (const char **) preview_values); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_PREVIEW_FOLDER_WIDGET, NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS, (const char **) preview_values); bind_builder_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET, NAUTILUS_PREFERENCES_DATE_FORMAT, (const char **) date_format_values); bind_builder_radio (builder, nautilus_preferences, (const char **) click_behavior_components, NAUTILUS_PREFERENCES_CLICK_POLICY, (const char **) click_behavior_values); bind_builder_radio (builder, nautilus_preferences, (const char **) executable_text_components, NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, (const char **) executable_text_values); bind_builder_uint_enum (builder, nautilus_preferences, NAUTILUS_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET, NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT, thumbnail_limit_values, G_N_ELEMENTS (thumbnail_limit_values)); nautilus_file_management_properties_dialog_setup_icon_caption_page (builder); nautilus_file_management_properties_dialog_setup_list_column_page (builder); /* UI callbacks */ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "file_management_dialog")); g_signal_connect_data (dialog, "response", G_CALLBACK (nautilus_file_management_properties_dialog_response_cb), g_object_ref (builder), (GClosureNotify)g_object_unref, 0); g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-file-manager"); if (window) { gtk_window_set_screen (GTK_WINDOW (dialog), gtk_window_get_screen(window)); } preferences_dialog = dialog; g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &preferences_dialog); gtk_widget_show (dialog); }
static void _settings_window(USSD * ussd) { GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * hbox; GtkWidget * image; GtkWidget * widget; size_t i; group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); ussd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(ussd->window), 4); gtk_window_set_default_size(GTK_WINDOW(ussd->window), 200, 300); #if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_icon_name(GTK_WINDOW(ussd->window), "gnome-settings"); #endif gtk_window_set_title(GTK_WINDOW(ussd->window), "USSD"); g_signal_connect(ussd->window, "delete-event", G_CALLBACK( gtk_widget_hide), NULL); #if GTK_CHECK_VERSION(3, 0, 0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); #else vbox = gtk_vbox_new(FALSE, 4); #endif /* operators */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new("Operator:"); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); #if GTK_CHECK_VERSION(3, 0, 0) ussd->operators = gtk_combo_box_text_new(); for(i = 0; _ussd_operators[i].name != NULL; i++) gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(ussd->operators), NULL, _ussd_operators[i].name); #else ussd->operators = gtk_combo_box_new_text(); for(i = 0; _ussd_operators[i].name != NULL; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(ussd->operators), _ussd_operators[i].name); #endif g_signal_connect_swapped(ussd->operators, "changed", G_CALLBACK( _ussd_on_operators_changed), ussd); gtk_box_pack_start(GTK_BOX(hbox), ussd->operators, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* codes */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new("Code:"); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); #if GTK_CHECK_VERSION(3, 0, 0) ussd->codes = gtk_combo_box_text_new(); #else ussd->codes = gtk_combo_box_new_text(); #endif gtk_box_pack_start(GTK_BOX(hbox), ussd->codes, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* send */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #else hbox = gtk_hbox_new(FALSE, 4); #endif widget = gtk_label_new(NULL); #if GTK_CHECK_VERSION(3, 0, 0) g_object_set(widget, "halign", GTK_ALIGN_START, NULL); #else gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); #endif gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); widget = gtk_button_new_with_label("Send request"); image = gtk_image_new_from_icon_name("mail-send", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(widget), image); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _ussd_on_settings_send), ussd); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* button box */ #if GTK_CHECK_VERSION(3, 0, 0) hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); #else hbox = gtk_hbutton_box_new(); #endif gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END); gtk_box_set_spacing(GTK_BOX(hbox), 4); widget = gtk_button_new_from_stock(GTK_STOCK_CLOSE); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _ussd_on_settings_close), ussd); gtk_container_add(GTK_CONTAINER(hbox), widget); gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_container_add(GTK_CONTAINER(ussd->window), vbox); gtk_combo_box_set_active(GTK_COMBO_BOX(ussd->operators), 0); gtk_widget_show_all(vbox); }
/** * main: **/ int main (int argc, char *argv[]) { GOptionContext *context; guint retval = 0; GError *error = NULL; GMainLoop *loop; GtkWidget *main_window; GtkWidget *widget; UniqueApp *unique_app; guint xid = 0; McmColorimeter *colorimeter = NULL; const GOptionEntry options[] = { { "parent-window", 'p', 0, G_OPTION_ARG_INT, &xid, /* TRANSLATORS: we can make this modal (stay on top of) another window */ _("Set the parent window to make this modal"), NULL }, { NULL} }; /* setup translations */ setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* setup LCMS */ cmsSetLogErrorHandler (mcm_picker_error_cb); context = g_option_context_new (NULL); /* TRANSLATORS: tool that is used to pick colors */ g_option_context_set_summary (context, _("MATE Color Manager Color Picker")); g_option_context_add_group (context, egg_debug_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, NULL); g_option_context_parse (context, &argc, &argv, NULL); g_option_context_free (context); /* block in a loop */ loop = g_main_loop_new (NULL, FALSE); /* are we already activated? */ unique_app = unique_app_new ("org.mate.ColorManager.Picker", NULL); if (unique_app_is_running (unique_app)) { egg_debug ("You have another instance running. This program will now close"); unique_app_send_message (unique_app, UNIQUE_ACTIVATE, NULL); goto out; } g_signal_connect (unique_app, "message-received", G_CALLBACK (mcm_picker_message_received_cb), NULL); /* get UI */ builder = gtk_builder_new (); retval = gtk_builder_add_from_file (builder, MCM_DATA "/mcm-picker.ui", &error); if (retval == 0) { egg_warning ("failed to load ui: %s", error->message); g_error_free (error); goto out; } main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_picker")); gtk_window_set_icon_name (GTK_WINDOW (main_window), MCM_STOCK_ICON); g_signal_connect (main_window, "delete_event", G_CALLBACK (mcm_picker_delete_event_cb), loop); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_close")); g_signal_connect (widget, "clicked", G_CALLBACK (mcm_picker_close_cb), loop); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_help")); g_signal_connect (widget, "clicked", G_CALLBACK (mcm_picker_help_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_measure")); g_signal_connect (widget, "clicked", G_CALLBACK (mcm_picker_measure_cb), NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "image_preview")); gtk_widget_set_size_request (widget, 200, 200); /* add application specific icons to search path */ gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), MCM_DATA G_DIR_SEPARATOR_S "icons"); /* use the color device */ colorimeter = mcm_colorimeter_new (); g_signal_connect (colorimeter, "changed", G_CALLBACK (mcm_picker_colorimeter_changed_cb), NULL); /* set the parent window if it is specified */ if (xid != 0) { egg_debug ("Setting xid %i", xid); mcm_window_set_parent_xid (GTK_WINDOW (main_window), xid); } /* use argyll */ calibrate = MCM_CALIBRATE (mcm_calibrate_argyll_new ()); g_signal_connect (calibrate, "notify::xyz", G_CALLBACK (mcm_picker_xyz_notify_cb), NULL); /* use an info bar if there is no device, or the wrong device */ info_bar_hardware = gtk_info_bar_new (); info_bar_hardware_label = gtk_label_new (NULL); gtk_info_bar_set_message_type (GTK_INFO_BAR(info_bar_hardware), GTK_MESSAGE_INFO); widget = gtk_info_bar_get_content_area (GTK_INFO_BAR(info_bar_hardware)); gtk_container_add (GTK_CONTAINER(widget), info_bar_hardware_label); gtk_widget_show (info_bar_hardware_label); /* add infobar to devices pane */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "vbox1")); gtk_box_pack_start (GTK_BOX(widget), info_bar_hardware, FALSE, FALSE, 0); /* disable some ui if no hardware */ mcm_picker_colorimeter_setup_ui (colorimeter); /* maintain a list of profiles */ profile_store = mcm_profile_store_new (); /* default to AdobeRGB */ profile_filename = "/usr/share/color/icc/Argyll/ClayRGB1998.icm"; /* setup RGB combobox */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_colorspace")); mcm_prefs_set_combo_simple_text (widget); mcm_prefs_setup_space_combobox (widget); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (mcm_prefs_space_combo_changed_cb), NULL); /* setup results expander */ mcm_picker_refresh_results (); /* setup initial preview window */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "image_preview")); gtk_image_set_from_file (GTK_IMAGE (widget), DATADIR "/icons/hicolor/64x64/apps/mate-color-manager.png"); /* wait */ gtk_widget_show (main_window); g_main_loop_run (loop); out: g_object_unref (unique_app); if (profile_store != NULL) g_object_unref (profile_store); if (colorimeter != NULL) g_object_unref (colorimeter); if (calibrate != NULL) g_object_unref (calibrate); if (builder != NULL) g_object_unref (builder); g_main_loop_unref (loop); return retval; }
static GObject * ephy_permissions_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { EphyPermissionsDialog *dialog; EphyPermissionsDialogPrivate *priv; EphyEmbedShell *shell; EphyPermissionManager *manager; GObject *object; GtkWidget *notebook; object = parent_class->constructor (type, n_construct_properties, construct_params); dialog = EPHY_PERMISSIONS_DIALOG (object); priv = dialog->priv; ephy_state_add_window (GTK_WIDGET (dialog), "permissions-manager", 540, 400, FALSE, EPHY_STATE_WINDOW_SAVE_SIZE); gtk_window_set_title (GTK_WINDOW (dialog), _("Site Permissions")); gtk_window_set_role (GTK_WINDOW (dialog), "epiphany-permissions-manager"); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_PROPERTIES /* FIXME? */); /* Don't stay on top of all windows! */ gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, GTK_RESPONSE_HELP); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); notebook = gtk_notebook_new (); priv->notebook = GTK_NOTEBOOK (notebook); gtk_container_set_border_width (GTK_CONTAINER (priv->notebook), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), notebook, TRUE, TRUE, 0); gtk_widget_show (notebook); priv->buttons_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); ephy_permissions_dialog_add_tab (dialog, EPT_COOKIE, _("Cookies")); ephy_permissions_dialog_add_tab (dialog, EPT_IMAGE, _("Images")); ephy_permissions_dialog_add_tab (dialog, EPT_POPUP, _("Popup Windows")); /* ephy_permissions_dialog_add_tab (dialog, "password", _("Passwords")); */ shell = ephy_embed_shell_get_default (); priv->manager = manager = EPHY_PERMISSION_MANAGER (ephy_embed_shell_get_embed_single (shell)); sync_notebook_tab (priv->notebook, NULL, 0, dialog); g_signal_connect (G_OBJECT (notebook), "switch-page", G_CALLBACK (sync_notebook_tab), dialog); g_signal_connect (priv->manager, "permission-added", G_CALLBACK (permission_added_cb), dialog); g_signal_connect (priv->manager, "permission-changed", G_CALLBACK (permission_changed_cb), dialog); g_signal_connect (priv->manager, "permission-deleted", G_CALLBACK (permission_deleted_cb), dialog); g_signal_connect (priv->manager, "permissions-cleared", G_CALLBACK (permissions_cleared_cb), dialog); return object; }
GtkWidget* create_window_gshpvoronoi (void) { GtkWidget *window_gshpvoronoi; GtkWidget *vbox1; GtkWidget *menubar1; GtkWidget *menuitem1; GtkWidget *menuitem1_menu; GtkWidget *separatormenuitem1; GtkWidget *quit_gshpvoronoi; GtkWidget *menuitem4; GtkWidget *menuitem4_menu; GtkWidget *help_gshpvoronoi; GtkWidget *separator1; GtkWidget *about_gshpvoronoi; GtkWidget *frame_input; GtkWidget *alignment2; GtkWidget *filechooserbutton_input; GtkWidget *label_input; GtkWidget *frame1; GtkWidget *alignment1; GtkWidget *filechooserwidget_output; GtkWidget *label_output; GtkWidget *hbuttonbox1; GtkWidget *button_cancel; GtkWidget *button_ok; GtkWidget *statusbar_gshpvoronoi; GtkAccelGroup *accel_group; accel_group = gtk_accel_group_new (); window_gshpvoronoi = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window_gshpvoronoi), _("gshpvoronoi")); gtk_window_set_icon_name (GTK_WINDOW (window_gshpvoronoi), "gtk-execute"); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (window_gshpvoronoi), vbox1); menubar1 = gtk_menu_bar_new (); gtk_widget_show (menubar1); gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File")); gtk_widget_show (menuitem1); gtk_container_add (GTK_CONTAINER (menubar1), menuitem1); menuitem1_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu); separatormenuitem1 = gtk_separator_menu_item_new (); gtk_widget_show (separatormenuitem1); gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1); gtk_widget_set_sensitive (separatormenuitem1, FALSE); quit_gshpvoronoi = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); gtk_widget_show (quit_gshpvoronoi); gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit_gshpvoronoi); menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_widget_show (menuitem4); gtk_container_add (GTK_CONTAINER (menubar1), menuitem4); menuitem4_menu = gtk_menu_new (); gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); help_gshpvoronoi = gtk_image_menu_item_new_from_stock ("gtk-help", accel_group); gtk_widget_show (help_gshpvoronoi); gtk_container_add (GTK_CONTAINER (menuitem4_menu), help_gshpvoronoi); separator1 = gtk_separator_menu_item_new (); gtk_widget_show (separator1); gtk_container_add (GTK_CONTAINER (menuitem4_menu), separator1); gtk_widget_set_sensitive (separator1, FALSE); about_gshpvoronoi = gtk_menu_item_new_with_mnemonic (_("_About")); gtk_widget_show (about_gshpvoronoi); gtk_container_add (GTK_CONTAINER (menuitem4_menu), about_gshpvoronoi); frame_input = gtk_frame_new (NULL); gtk_widget_show (frame_input); gtk_box_pack_start (GTK_BOX (vbox1), frame_input, FALSE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame_input), 4); alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_widget_show (alignment2); gtk_container_add (GTK_CONTAINER (frame_input), alignment2); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0); filechooserbutton_input = gtk_file_chooser_button_new (_("Select A File"), GTK_FILE_CHOOSER_ACTION_OPEN); gtk_widget_show (filechooserbutton_input); gtk_container_add (GTK_CONTAINER (alignment2), filechooserbutton_input); label_input = gtk_label_new (_("<b>Input</b>")); gtk_widget_show (label_input); gtk_frame_set_label_widget (GTK_FRAME (frame_input), label_input); gtk_label_set_use_markup (GTK_LABEL (label_input), TRUE); frame1 = gtk_frame_new (NULL); gtk_widget_show (frame1); gtk_box_pack_start (GTK_BOX (vbox1), frame1, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (frame1), 4); alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1); gtk_widget_show (alignment1); gtk_container_add (GTK_CONTAINER (frame1), alignment1); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0); filechooserwidget_output = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE); gtk_widget_show (filechooserwidget_output); gtk_container_add (GTK_CONTAINER (alignment1), filechooserwidget_output); label_output = gtk_label_new (_("<b>Output</b>")); gtk_widget_show (label_output); gtk_frame_set_label_widget (GTK_FRAME (frame1), label_output); gtk_label_set_use_markup (GTK_LABEL (label_output), TRUE); hbuttonbox1 = gtk_hbutton_box_new (); gtk_widget_show (hbuttonbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, FALSE, TRUE, 0); gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END); button_cancel = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (button_cancel); gtk_container_add (GTK_CONTAINER (hbuttonbox1), button_cancel); GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); button_ok = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (button_ok); gtk_container_add (GTK_CONTAINER (hbuttonbox1), button_ok); GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); statusbar_gshpvoronoi = gtk_statusbar_new (); gtk_widget_show (statusbar_gshpvoronoi); gtk_box_pack_start (GTK_BOX (vbox1), statusbar_gshpvoronoi, FALSE, FALSE, 0); g_signal_connect ((gpointer) quit_gshpvoronoi, "activate", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect ((gpointer) help_gshpvoronoi, "activate", G_CALLBACK (on_help_gshpvoronoi_activate), NULL); g_signal_connect ((gpointer) about_gshpvoronoi, "activate", G_CALLBACK (on_about_gshpvoronoi_activate), NULL); g_signal_connect ((gpointer) filechooserbutton_input, "realize", G_CALLBACK (on_filechooserbutton_input_realize), NULL); g_signal_connect_swapped ((gpointer) button_cancel, "clicked", G_CALLBACK (gtk_main_quit), GTK_OBJECT (window_gshpvoronoi)); g_signal_connect ((gpointer) button_ok, "clicked", G_CALLBACK (on_button_ok_clicked), NULL); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (window_gshpvoronoi, window_gshpvoronoi, "window_gshpvoronoi"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, vbox1, "vbox1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, menubar1, "menubar1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, menuitem1, "menuitem1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, menuitem1_menu, "menuitem1_menu"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, separatormenuitem1, "separatormenuitem1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, quit_gshpvoronoi, "quit_gshpvoronoi"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, menuitem4, "menuitem4"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, menuitem4_menu, "menuitem4_menu"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, help_gshpvoronoi, "help_gshpvoronoi"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, separator1, "separator1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, about_gshpvoronoi, "about_gshpvoronoi"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, frame_input, "frame_input"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, alignment2, "alignment2"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, filechooserbutton_input, "filechooserbutton_input"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, label_input, "label_input"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, frame1, "frame1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, alignment1, "alignment1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, filechooserwidget_output, "filechooserwidget_output"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, label_output, "label_output"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, hbuttonbox1, "hbuttonbox1"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, button_cancel, "button_cancel"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, button_ok, "button_ok"); GLADE_HOOKUP_OBJECT (window_gshpvoronoi, statusbar_gshpvoronoi, "statusbar_gshpvoronoi"); gtk_window_add_accel_group (GTK_WINDOW (window_gshpvoronoi), accel_group); return window_gshpvoronoi; }
static GtkWidget * csm_get_dialog (CsmDialogLogoutType type, GdkScreen *screen, guint32 activate_time) { CsmLogoutDialog *logout_dialog; GtkWidget *hbox; const char *primary_text; const char *icon_name; if (current_dialog != NULL) { gtk_widget_destroy (GTK_WIDGET (current_dialog)); } logout_dialog = g_object_new (CSM_TYPE_LOGOUT_DIALOG, NULL); current_dialog = logout_dialog; gtk_window_set_title (GTK_WINDOW (logout_dialog), _("Session")); logout_dialog->priv->type = type; GSettings *settings = g_settings_new (SESSION_SCHEMA); logout_dialog->priv->delay_toggle = g_settings_get_boolean (settings, KEY_TOGGLE_DELAY); logout_dialog->priv->delay = g_settings_get_int (settings, KEY_DELAY); icon_name = NULL; primary_text = NULL; switch (type) { case CSM_DIALOG_LOGOUT_TYPE_LOGOUT: icon_name = CSM_ICON_LOGOUT; primary_text = _("Log out of this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_LOGOUT; if (csm_logout_supports_switch_user (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Switch User"), CSM_LOGOUT_RESPONSE_SWITCH_USER); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Log Out"), CSM_LOGOUT_RESPONSE_LOGOUT); break; case CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: icon_name = CSM_ICON_SHUTDOWN; primary_text = _("Shut down this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_SHUTDOWN; if (csm_system_can_suspend (logout_dialog->priv->system)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("S_uspend"), CSM_LOGOUT_RESPONSE_SLEEP); } if (csm_system_can_hibernate (logout_dialog->priv->system)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Hibernate"), CSM_LOGOUT_RESPONSE_HIBERNATE); } if (csm_logout_supports_reboot (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Restart"), CSM_LOGOUT_RESPONSE_REBOOT); } gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); if (csm_logout_supports_shutdown (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Shut Down"), CSM_LOGOUT_RESPONSE_SHUTDOWN); } break; case CSM_DIALOG_LOGOUT_TYPE_REBOOT: icon_name = CSM_ICON_SHUTDOWN; primary_text = _("Restart this system now?"); logout_dialog->priv->default_response = CSM_LOGOUT_RESPONSE_REBOOT; gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); if (csm_logout_supports_reboot (logout_dialog)) { gtk_dialog_add_button (GTK_DIALOG (logout_dialog), _("_Restart"), CSM_LOGOUT_RESPONSE_REBOOT); } break; default: g_assert_not_reached (); } if (logout_dialog->priv->delay_toggle) { hbox = gtk_box_new (FALSE, 0); logout_dialog->priv->progressbar = gtk_progress_bar_new (); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->priv->progressbar), 1.0); gtk_box_pack_start (GTK_BOX (hbox), logout_dialog->priv->progressbar, TRUE, TRUE, 12); gtk_widget_show_all (hbox); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), hbox); } gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name); gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER); gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text); gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog), logout_dialog->priv->default_response); gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen); g_object_unref(settings); return GTK_WIDGET (logout_dialog); }
static void empathy_preferences_init (EmpathyPreferences *preferences) { EmpathyPreferencesPriv *priv; GtkBuilder *gui; gchar *filename; GtkWidget *page; priv = preferences->priv = G_TYPE_INSTANCE_GET_PRIVATE (preferences, EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesPriv); gtk_dialog_add_button (GTK_DIALOG (preferences), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_container_set_border_width (GTK_CONTAINER (preferences), 5); gtk_window_set_title (GTK_WINDOW (preferences), _("Preferences")); gtk_window_set_role (GTK_WINDOW (preferences), "preferences"); gtk_window_set_position (GTK_WINDOW (preferences), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_icon_name (GTK_WINDOW (preferences), "gtk-preferences"); filename = empathy_file_lookup ("empathy-preferences.ui", "src"); gui = empathy_builder_get_file (filename, "notebook", &priv->notebook, "checkbutton_show_smileys", &priv->checkbutton_show_smileys, "checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms, "vbox_chat_theme", &priv->vbox_chat_theme, "combobox_chat_theme", &priv->combobox_chat_theme, "combobox_chat_theme_variant", &priv->combobox_chat_theme_variant, "hbox_chat_theme_variant", &priv->hbox_chat_theme_variant, "sw_chat_theme_preview", &priv->sw_chat_theme_preview, "radiobutton_chats_new_windows", &priv->radiobutton_chats_new_windows, "checkbutton_events_notif_area", &priv->checkbutton_events_notif_area, "checkbutton_autoconnect", &priv->checkbutton_autoconnect, "checkbutton_logging", &priv->checkbutton_logging, "checkbutton_notifications_enabled", &priv->checkbutton_notifications_enabled, "checkbutton_notifications_disabled_away", &priv->checkbutton_notifications_disabled_away, "checkbutton_notifications_focus", &priv->checkbutton_notifications_focus, "checkbutton_notifications_contact_signin", &priv->checkbutton_notifications_contact_signin, "checkbutton_notifications_contact_signout", &priv->checkbutton_notifications_contact_signout, "checkbutton_sounds_enabled", &priv->checkbutton_sounds_enabled, "checkbutton_sounds_disabled_away", &priv->checkbutton_sounds_disabled_away, "treeview_sounds", &priv->treeview_sounds, "treeview_spell_checker", &priv->treeview_spell_checker, "checkbutton_location_publish", &priv->checkbutton_location_publish, "checkbutton_location_reduce_accuracy", &priv->checkbutton_location_reduce_accuracy, "checkbutton_location_resource_network", &priv->checkbutton_location_resource_network, "checkbutton_location_resource_cell", &priv->checkbutton_location_resource_cell, "checkbutton_location_resource_gps", &priv->checkbutton_location_resource_gps, "call_echo_cancellation", &priv->echo_cancellation, NULL); g_free (filename); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (preferences))), priv->notebook); gtk_widget_show (priv->notebook); g_object_unref (gui); priv->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA); priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA); priv->gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA); priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA); priv->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA); priv->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA); priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA); priv->gsettings_logger = g_settings_new (EMPATHY_PREFS_LOGGER_SCHEMA); /* Create chat theme preview, and track changes */ priv->theme_manager = empathy_theme_manager_dup_singleton (); tp_g_signal_connect_object (priv->theme_manager, "theme-changed", G_CALLBACK (preferences_preview_theme_changed_cb), preferences, 0); preferences_preview_theme_changed_cb (priv->theme_manager, preferences); preferences_themes_setup (preferences); preferences_setup_widgets (preferences); preferences_languages_setup (preferences); preferences_languages_add (preferences); preferences_languages_load (preferences); preferences_sound_setup (preferences); preferences_sound_load (preferences); if (empathy_spell_supported ()) { page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL); gtk_widget_show (page); } page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_LOCATION); #ifdef HAVE_GEOCLUE gtk_widget_show (page); #else gtk_widget_hide (page); #endif }
static Debug * _debug_init(PhonePluginHelper * helper) { Debug * debug; GtkSizeGroup * group; GtkWidget * vbox; GtkWidget * widget; GtkWidget * hbox; GtkCellRenderer * renderer; GtkTreeViewColumn * column; size_t i; if((debug = object_new(sizeof(*debug))) == NULL) return NULL; debug->helper = helper; group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); debug->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(debug->window), 200, 300); #if GTK_CHECK_VERSION(2, 6, 0) gtk_window_set_icon_name(GTK_WINDOW(debug->window), plugin.icon); #endif gtk_window_set_title(GTK_WINDOW(debug->window), plugin.name); g_signal_connect_swapped(debug->window, "delete-event", G_CALLBACK( _debug_on_closex), debug); /* vbox */ vbox = gtk_vbox_new(FALSE, 0); /* modem requests */ hbox = gtk_hbox_new(FALSE, 4); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); #if GTK_CHECK_VERSION(3, 0, 0) debug->requests = gtk_combo_box_text_new(); for(i = 0; _debug_modem_requests[i].name != NULL; i++) gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(debug->requests), NULL, _debug_modem_requests[i].name); #else debug->requests = gtk_combo_box_new_text(); for(i = 0; _debug_modem_requests[i].name != NULL; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(debug->requests), _debug_modem_requests[i].name); #endif gtk_combo_box_set_active(GTK_COMBO_BOX(debug->requests), 0); gtk_box_pack_start(GTK_BOX(hbox), debug->requests, TRUE, TRUE, 0); widget = gtk_button_new_from_stock(GTK_STOCK_EXECUTE); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _debug_on_queue_request), debug); gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* modem triggers */ hbox = gtk_hbox_new(FALSE, 4); gtk_container_set_border_width(GTK_CONTAINER(hbox), 4); #if GTK_CHECK_VERSION(3, 0, 0) debug->triggers = gtk_combo_box_text_new(); for(i = 0; _debug_modem_triggers[i].name != NULL; i++) gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(debug->triggers), NULL, _debug_modem_triggers[i].name); #else debug->triggers = gtk_combo_box_new_text(); for(i = 0; _debug_modem_triggers[i].name != NULL; i++) gtk_combo_box_append_text(GTK_COMBO_BOX(debug->triggers), _debug_modem_triggers[i].name); #endif gtk_combo_box_set_active(GTK_COMBO_BOX(debug->triggers), 0); gtk_box_pack_start(GTK_BOX(hbox), debug->triggers, TRUE, TRUE, 0); widget = gtk_button_new_from_stock(GTK_STOCK_REFRESH); g_signal_connect_swapped(widget, "clicked", G_CALLBACK( _debug_on_queue_trigger), debug); gtk_size_group_add_widget(group, widget); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); /* events */ debug->events = gtk_list_store_new(3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); widget = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); debug->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL( debug->events)); gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(debug->view), TRUE); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Time", renderer, "text", 1, NULL); gtk_tree_view_column_set_sort_column_id(column, 0); gtk_tree_view_append_column(GTK_TREE_VIEW(debug->view), column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Event", renderer, "text", 2, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(debug->view), column); gtk_container_add(GTK_CONTAINER(widget), debug->view); gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(debug->window), vbox); gtk_widget_show_all(debug->window); return debug; }