void bluetooth_configure (XfcePanelPlugin *plugin, bluetoothPlugin *bluetooth) { GtkWidget *dialog; /* block the plugin menu */ xfce_panel_plugin_block_menu (plugin); /* create the dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("bluetooth Plugin"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); /* center dialog on the screen */ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); /* set dialog icon */ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings"); /* link the dialog to the plugin, so we can destroy it when the plugin * is closed, but the dialog is still open */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); /* connect the reponse signal to the dialog */ g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(bluetooth_configure_response), bluetooth); /* show the entire dialog */ gtk_widget_show (dialog); }
void xtp_build_config_dialog(XfceTextPluginData *xtpd) { GtkWidget *box_root = NULL; GtkWindow *parent_window; xpf("xtp_build_config_dialog()\n"); parent_window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(xtpd->plugin))); #if 0 xtpd->cfg = xfce_titled_dialog_new_with_buttons( // why doesn't this work? _("Text Plugin Configuration"), parent_window, GTK_DIALOG_DESTROY_WITH_PARENT, // | GTK_DIALOG_NO_SEPARATOR[deprecated], GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); #elif 0 xtpd->cfg = xfce_titled_dialog_new(); #else xtpd->cfg = gtk_dialog_new_with_buttons( _("Text Plugin Configuration"), parent_window, GTK_DIALOG_DESTROY_WITH_PARENT, // GTK_STOCK_HELP , GTK_RESPONSE_HELP, // GtkStock deprecated: how to replace? GTK_STOCK_OK , GTK_RESPONSE_ACCEPT, // _("_OK") , GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, // _("_Cancel") , GTK_RESPONSE_REJECT, GTK_STOCK_APPLY , GTK_RESPONSE_APPLY , NULL); #endif gtk_window_set_icon_name(GTK_WINDOW(xtpd->cfg), "xfce4-settings"); box_root = gtk_dialog_get_content_area(GTK_DIALOG(xtpd->cfg)); gtk_container_set_border_width(GTK_CONTAINER(box_root), BORDER - 2); gtk_orientable_set_orientation(GTK_ORIENTABLE(box_root), GTK_ORIENTATION_VERTICAL); xtp_build_config_dialog_frame(xtpd->ll.name, &(xtpd->ll), FALSE, TRUE ); xtp_build_config_dialog_frame(xtpd->tt.name, &(xtpd->tt), TRUE , TRUE ); xtp_build_config_dialog_frame(xtpd->pp.name, &(xtpd->pp), TRUE , TRUE ); /* put everything in the dialog */ gtk_box_pack_start(GTK_BOX(box_root), xtpd->ll.frm, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(box_root), xtpd->tt.frm, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(box_root), xtpd->pp.frm, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(xtpd->cfg), "response" , G_CALLBACK(xtp_config_dialog_response ), xtpd); g_signal_connect(G_OBJECT(xtpd->cfg), "show" , G_CALLBACK(xtp_config_dialog_show ), xtpd); g_signal_connect(G_OBJECT(xtpd->cfg), "hide" , G_CALLBACK(xtp_config_dialog_hide ), xtpd); g_signal_connect(G_OBJECT(xtpd->cfg), "delete-event", G_CALLBACK(xtp_config_dialog_prevent_delete), xtpd); }
void sample_configure (XfcePanelPlugin *plugin, ActiveAppPlugin *sample) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *tooltip_checkbox; /* block the plugin menu */ xfce_panel_plugin_block_menu (plugin); /* create the dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("Active Application Plugin"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); /* center dialog on the screen */ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); /* set dialog icon */ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings"); /* link the dialog to the plugin, so we can destroy it when the plugin * is closed, but the dialog is still open */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); tooltip_checkbox = gtk_check_button_new_with_label ("Show tooltips"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tooltip_checkbox), sample->show_tooltips); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), tooltip_checkbox, TRUE, TRUE, 6); gtk_widget_show (tooltip_checkbox); /* connect the reponse signal to the dialog */ g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(sample_configure_response), sample); g_signal_connect (G_OBJECT (tooltip_checkbox), "toggled", G_CALLBACK(activeapp_tooltip_checkbox_toggled), sample); /* show the entire dialog */ gtk_widget_show (dialog); }
void wckbuttons_configure (XfcePanelPlugin *plugin, WBPlugin *wb) { GtkWidget *dialog; GtkWidget *content_area; GtkWidget *ca; const gchar *name; /* block the plugin menu */ xfce_panel_plugin_block_menu (plugin); /* create the dialog */ name = xfce_panel_plugin_get_display_name (plugin); dialog = xfce_titled_dialog_new_with_buttons (_(name), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); /* center dialog on the screen */ gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); /* set dialog icon */ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings"); /* link the dialog to the plugin, so we can destroy it when the plugin * is closed, but the dialog is still open */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); /* connect the reponse signal to the dialog */ g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(wckbuttons_configure_response), wb); content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog) ); ca = build_properties_area (wb, wckbuttons_dialogs_ui, wckbuttons_dialogs_ui_length); if (G_LIKELY (ca != NULL)) gtk_container_add(GTK_CONTAINER (content_area), ca); else DBG("Failed to create content area"); /* show the entire dialog */ gtk_widget_show (dialog); }
static GtkWidget* pcfg_make_empty_dialog(PlacesCfg *cfg) { GtkWidget *dlg; /* we'll return this */ xfce_panel_plugin_block_menu(cfg->plugin); dlg = xfce_titled_dialog_new_with_buttons(_("Places"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT, NULL); gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); gtk_window_set_icon_name(GTK_WINDOW(dlg), "xfce4-settings"); g_signal_connect(dlg, "response", G_CALLBACK(pcfg_dialog_close_cb), cfg); return dlg; }
static void fortune_fish_plugin_settings(fortune_fish_plugin *fish_plugin) { GtkWidget *dialog, *content_area, *settings; xfce_panel_plugin_block_menu(fish_plugin->plugin); dialog = xfce_titled_dialog_new_with_buttons("Fortune Fish", GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(fish_plugin->plugin))), GTK_DIALOG_DESTROY_WITH_PARENT, "_Close", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle(XFCE_TITLED_DIALOG(dialog), "Settings"); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name(GTK_WINDOW(dialog), "fortune-fish"); settings = fortune_fish_settings_new(fish_plugin->fish); content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_container_add(GTK_CONTAINER(content_area), settings); g_signal_connect_swapped(dialog, "response", G_CALLBACK(fortune_fish_plugin_settings_close), fish_plugin); gtk_widget_show_all(dialog); }
void lightdash_configure (XfcePanelPlugin *plugin, LightdashPlugin *lightdash) { GtkWidget *dialog; GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; GtkWidget *opacity_slider; GtkWidget *show_desktop_button; GtkWidget *toplevel; GtkWindow *window; window = NULL; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (plugin)); if (gtk_widget_is_toplevel (toplevel)) { window = GTK_WINDOW (toplevel); } xfce_panel_plugin_block_menu (plugin); dialog = xfce_titled_dialog_new_with_buttons (_("lightdash"), window, GTK_DIALOG_DESTROY_WITH_PARENT #if GTK_CHECK_VERSION (3, 0, 0) #else | GTK_DIALOG_NO_SEPARATOR #endif , GTK_STOCK_HELP, GTK_RESPONSE_HELP, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); #if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #else hbox = gtk_hbox_new (FALSE, 0); #endif label = gtk_label_new_with_mnemonic (_("_Title:")); entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (entry), gtk_label_get_text (GTK_LABEL (lightdash->button_label))); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (lightdash_preferences_entry_changed), lightdash); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 6); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 6); gtk_widget_show_all (hbox); #if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #else hbox = gtk_hbox_new (FALSE, 0); #endif opacity_slider = gtk_hscale_new_with_range (0.0, 100.0, 1.0); gtk_scale_set_value_pos (GTK_SCALE (opacity_slider), GTK_POS_RIGHT); gtk_widget_set_size_request (GTK_WIDGET (opacity_slider), 200, -1); gtk_range_set_value (GTK_RANGE (opacity_slider), lightdash->opacity); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 6); label = gtk_label_new_with_mnemonic (_("Background opacit_y:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); gtk_box_pack_start (GTK_BOX (hbox), opacity_slider, TRUE, TRUE, 6); g_signal_connect (G_OBJECT (opacity_slider), "value-changed", G_CALLBACK (lightdash_opacity_slider_changed), lightdash); gtk_widget_show_all (hbox); show_desktop_button = gtk_check_button_new_with_label (_("Show desktop behind dashboard")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_desktop_button), lightdash->show_desktop); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), show_desktop_button, TRUE, TRUE, 6); g_signal_connect (G_OBJECT (show_desktop_button), "toggled", G_CALLBACK (lightdash_show_desktop_button_toggled), lightdash); g_object_set_data (G_OBJECT (plugin), "dialog", dialog); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (lightdash_configure_response), lightdash); gtk_widget_show_all (dialog); }
void net_speed_configure_show(XfcePanelPlugin *plugin, NetSpeedPlugin *net_speed_plugin) { GtkWidget *dialog; GtkWidget *dialog_vbox; GtkWidget *hbox; GtkWidget *label; GtkWidget *combo; GtkWidget *button; /* net speed configure */ NetSpeedConfigure *net_speed_configure = g_new0(NetSpeedConfigure, 1); net_speed_configure->net_speed_plugin = net_speed_plugin; /* dialog */ xfce_panel_plugin_block_menu(net_speed_plugin->plugin); net_speed_configure->dialog = dialog = xfce_titled_dialog_new_with_buttons(_("Network Speed Plugin"), NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle(XFCE_TITLED_DIALOG(dialog), _("Configuration")); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name(GTK_WINDOW(dialog), "xfce4-netspeed-plugin"); gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); gtk_window_stick(GTK_WINDOW(dialog)); dialog_vbox = GTK_DIALOG(dialog)->vbox; /* auto-device */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->auto_device_check_button = button = gtk_check_button_new_with_mnemonic(_("Automatically Choose Network Device")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), net_speed_plugin->options->device_auto == TRUE); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); /* device */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); label = gtk_label_new(_("Network Device:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); net_speed_configure->device_combo = combo = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, TRUE, 0); GList *device, *devices = device_info_list_get(); gint index = 0, sel_index = -1; for (device = devices; device != NULL; device = g_list_next(device)) { gtk_combo_box_append_text(GTK_COMBO_BOX(combo), device->data); if (net_speed_plugin->options->device && !strcmp(device->data, net_speed_plugin->options->device)) { sel_index = index; } index++; } gtk_combo_box_set_active(GTK_COMBO_BOX(combo), sel_index); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(net_speed_configure_changed), net_speed_configure); device_info_list_free(devices); gtk_widget_set_sensitive(net_speed_configure->device_combo, net_speed_plugin->options->device != NULL); /* show frame */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->show_frame_check_button = button = gtk_check_button_new_with_mnemonic(_("Show Frame")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), net_speed_plugin->options->show_frame); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); /* show icon */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->show_icon_check_button = button = gtk_check_button_new_with_mnemonic(_("Show Icon")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), net_speed_plugin->options->show_icon); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); /* show bits */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->show_bits_check_button = button = gtk_check_button_new_with_mnemonic(_("Show Bits Instead of Bytes")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), net_speed_plugin->options->show_bits); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); /* show sum */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->show_sum_check_button = button = gtk_check_button_new_with_mnemonic(_("Show Sum of Download and Upload")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), net_speed_plugin->options->show_sum); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); /* fixed width check button */ hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(dialog_vbox), hbox); gtk_container_set_border_width(GTK_CONTAINER(hbox), 3); net_speed_configure->fixed_width_check_button = button = gtk_check_button_new_with_mnemonic(_("Fixed Width")); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (gboolean) net_speed_plugin->options->fixed_width); g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(net_speed_configure_changed), net_speed_configure); net_speed_configure->fixed_width_spin_button = button = gtk_spin_button_new_with_range(20, 500, 10); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_spin_button_set_value(GTK_SPIN_BUTTON(button), (gdouble) net_speed_plugin->options->fixed_width); g_signal_connect(G_OBJECT(button), "value-changed", G_CALLBACK(net_speed_configure_changed), net_speed_configure); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(net_speed_configure_response), net_speed_configure); gtk_widget_show_all(dialog); }
gint main(gint argc, gchar **argv) { GtkWidget *dialog; GtkWidget *settings_editor; GtkWidget *plug; GError *error = NULL; /* setup translation domain */ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); /* initialize Gtk+ */ if (!gtk_init_with_args (&argc, &argv, "", option_entries, GETTEXT_PACKAGE, &error)) { if (G_LIKELY (error)) { /* print error */ g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message); g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN); g_print ("\n"); /* cleanup */ g_error_free (error); } else { g_error ("Unable to open display."); } return EXIT_FAILURE; } /* print version information */ if (G_UNLIKELY (opt_version)) { g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ()); g_print ("%s\n", "Copyright (c) 2008-2011"); g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved.")); g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT); g_print ("\n"); return EXIT_SUCCESS; } /* initialize xfconf */ if (G_UNLIKELY (!xfconf_init (&error))) { /* print error and leave */ g_critical ("Failed to connect to Xfconf daemon: %s", error->message); g_error_free (error); return EXIT_FAILURE; } channel = xfconf_channel_new ("xfce4-settings-editor"); settings_editor = xfce_settings_editor_box_new ( xfconf_channel_get_int (channel, "/last/paned-position", 180)); if (G_UNLIKELY (opt_socket_id == 0)) { dialog = xfce_titled_dialog_new_with_buttons (_("Settings Editor"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-help", GTK_RESPONSE_HELP, "gtk-close", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), _("Customize settings stored by Xfconf")); gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-system"); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_default_size (GTK_WINDOW (dialog), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_container_add_with_properties( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), settings_editor, "expand", TRUE, "fill", TRUE, NULL); g_signal_connect (dialog, "response", G_CALLBACK (settings_dialog_response), settings_editor); gtk_widget_show_all (dialog); } else { /* Create plug widget */ plug = gtk_plug_new (opt_socket_id); g_signal_connect (plug, "delete-event", G_CALLBACK (plug_delete_event), settings_editor); gtk_window_set_default_size (GTK_WINDOW (plug), xfconf_channel_get_int (channel, "/last/window-width", 640), xfconf_channel_get_int (channel, "/last/window-height", 500)); gtk_widget_show (plug); gtk_container_add (GTK_CONTAINER(plug), settings_editor); /* Stop startup notification */ gdk_notify_startup_complete (); gtk_widget_show (GTK_WIDGET (settings_editor)); } gtk_main (); g_object_unref(channel); /* shutdown xfconf */ xfconf_shutdown (); return EXIT_SUCCESS; }
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 xfpm_info_create (XfpmInfo *info) { GtkWidget *content_area; GtkWidget *hbox; GtkWidget *viewport; GtkListStore *list_store; GtkTreeViewColumn *col; GtkCellRenderer *renderer; info->dialog = xfce_titled_dialog_new_with_buttons (_("Power Information"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_window_set_position (GTK_WINDOW (info->dialog), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_default_size (GTK_WINDOW (info->dialog), -1, 400); gtk_window_set_icon_name (GTK_WINDOW (info->dialog), GTK_STOCK_INFO); content_area = gtk_dialog_get_content_area (GTK_DIALOG (info->dialog)); hbox = gtk_hbox_new (FALSE, 4); gtk_container_add (GTK_CONTAINER (content_area), hbox); viewport = gtk_viewport_new (NULL, NULL); info->sideview = gtk_tree_view_new (); list_store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); gtk_tree_view_set_model (GTK_TREE_VIEW (info->sideview), GTK_TREE_MODEL (list_store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (info->sideview),TRUE); col = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (col, renderer, FALSE); gtk_tree_view_column_set_attributes (col, renderer, "pixbuf", 0, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, renderer, FALSE); gtk_tree_view_column_set_attributes (col, renderer, "markup", 1, NULL); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (info->sideview), FALSE); gtk_tree_view_append_column (GTK_TREE_VIEW (info->sideview), col); g_signal_connect (info->sideview, "cursor-changed", G_CALLBACK (view_cursor_changed_cb), info); gtk_container_add (GTK_CONTAINER (viewport), info->sideview); gtk_box_pack_start (GTK_BOX (hbox), viewport, FALSE, FALSE, 0); info->notebook = gtk_notebook_new (); gtk_box_pack_start (GTK_BOX (hbox), info->notebook, TRUE, TRUE, 0); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (info->notebook), FALSE); /*Show power devices information, AC adapter, batteries*/ xfpm_info_power_devices (info); /*Sow CPU wakeups*/ xfpm_info_cpu_wakeups (info); g_object_set (G_OBJECT (hbox), "border-width", 4, NULL); gtk_widget_show_all (hbox); }
static void initiate_authentication(PolkitAgentListener *listener, const gchar *action_id, const gchar *message, const gchar *icon_name, PolkitDetails *details, const gchar *cookie, GList *identities, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GtkWidget *content; GtkWidget *combo_label; GtkWidget *grid; AuthDlgData *d = g_slice_new0(AuthDlgData); char** p; for(p = polkit_details_get_keys(details); *p; ++p) g_debug("initiate_authentication: %s: %s", *p, polkit_details_lookup(details, *p)); d->task = g_task_new(listener, cancellable, callback, user_data); d->cancellable = cancellable; d->action_id = g_strdup(action_id); d->cookie = g_strdup(cookie); d->auth_dlg = xfce_titled_dialog_new_with_buttons( "Authentication required", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "_Deny", GTK_RESPONSE_CANCEL, "_Allow", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle(XFCE_TITLED_DIALOG(d->auth_dlg), message); gtk_window_set_icon_name(GTK_WINDOW(d->auth_dlg), "dialog-password"); content = gtk_dialog_get_content_area(GTK_DIALOG(d->auth_dlg)); combo_label = gtk_label_new("Identity:"); gtk_widget_set_halign(combo_label, GTK_ALIGN_END); gtk_widget_show(combo_label); d->id_combo = gtk_combo_box_new(); add_identities(GTK_COMBO_BOX(d->id_combo), identities); g_signal_connect(d->id_combo, "changed", G_CALLBACK(on_id_combo_user_changed), d); gtk_combo_box_set_active(GTK_COMBO_BOX(d->id_combo), 0); gtk_widget_set_hexpand(d->id_combo, TRUE); gtk_widget_show(d->id_combo); d->entry_label = gtk_label_new(NULL); gtk_widget_set_halign(d->entry_label, GTK_ALIGN_END); gtk_widget_show(d->entry_label); d->entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(d->entry), FALSE); gtk_widget_set_hexpand(d->entry, TRUE); gtk_widget_show(d->entry); g_signal_connect (d->entry, "activate", G_CALLBACK(on_entry_activate), d); grid = grid2x2(combo_label, d->id_combo, d->entry_label, d->entry); gtk_box_pack_start(GTK_BOX(content), grid, TRUE, TRUE, 0); d->status = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(content), d->status, TRUE, TRUE, 0); gtk_widget_show(d->status); g_signal_connect(cancellable, "cancelled", G_CALLBACK(on_cancelled), d); g_signal_connect(d->auth_dlg, "response", G_CALLBACK(on_auth_dlg_response), d); gtk_widget_grab_focus(d->entry); gtk_window_present(GTK_WINDOW(d->auth_dlg)); }
static void power_manager_plugin_configure (XfcePanelPlugin *plugin, PowerManagerPlugin *power_manager_plugin) { GtkWidget *dialog; GtkWidget *grid, *combo, *label; gint show_panel_label; XfconfChannel *channel; GtkListStore *list_store; GtkTreeIter iter, active_iter; GtkCellRenderer *cell; gint i; gchar *options[] = { _("None"), _("Percentage"), _("Remaining time"), _("Percentage and remaining time") }; channel = xfconf_channel_get (XFPM_CHANNEL); /* block the plugin menu */ xfce_panel_plugin_block_menu (plugin); /* create the dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("Power Manager Plugin Settings"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-help", GTK_RESPONSE_HELP, "gtk-close", GTK_RESPONSE_OK, NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-power-manager-settings"); gtk_widget_show (dialog); /* Set up the main grid for all settings */ grid = gtk_grid_new (); gtk_grid_set_row_spacing (GTK_GRID (grid), 6); gtk_grid_set_column_spacing (GTK_GRID (grid), 12); gtk_widget_set_margin_start (grid, 12); gtk_widget_set_margin_end (grid, 12); gtk_widget_set_margin_top (grid, 12); gtk_widget_set_margin_bottom (grid, 12); gtk_container_add_with_properties (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), grid, "expand", TRUE, "fill", TRUE, NULL); /* show-panel-label setting */ label = gtk_label_new (_("Show label:")); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (label), 0, 0, 1, 1); show_panel_label = xfconf_channel_get_int (channel, XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, -1); list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_INT, G_TYPE_STRING); for (i = 0; i < 4; i++) { gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, COLUMN_INT, i, COLUMN_STRING, options[i], -1); if (i == show_panel_label) active_iter = iter; } combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE ); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, "text", COLUMN_STRING, NULL); gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), COLUMN_STRING); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &active_iter); gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (combo), 1, 0, 1, 1); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (power_manager_plugin_combo_changed), channel); g_signal_connect (G_OBJECT (channel), "property-changed::" XFPM_PROPERTIES_PREFIX SHOW_PANEL_LABEL, G_CALLBACK (power_manager_plugin_panel_label_changed), combo); /* link the dialog to the plugin, so we can destroy it when the plugin * is closed, but the dialog is still open */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK(power_manager_plugin_configure_response), power_manager_plugin); gtk_widget_show_all (grid); }
static void time_out_configure (XfcePanelPlugin *plugin, TimeOutPlugin *time_out) { GtkWidget *dialog; GtkWidget *framebox; GtkWidget *timebin; GtkWidget *behaviourbin; GtkWidget *appearancebin; GtkWidget *table; GtkWidget *vbox; GtkWidget *label; GtkWidget *spin; GtkWidget *checkbutton; g_return_if_fail (plugin != NULL); g_return_if_fail (time_out != NULL); /* Pause break timer for the time we're configuring */ if (G_LIKELY (time_out_countdown_get_running (time_out->break_countdown))) time_out_countdown_pause (time_out->break_countdown); /* Block plugin context menu */ xfce_panel_plugin_block_menu (plugin); /* Create properties dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("Time Out"), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (plugin))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); /* Set dialog property */ g_object_set_data (G_OBJECT (plugin), "dialog", dialog); /* Be notified when the properties dialog is closed */ g_signal_connect (dialog, "response", G_CALLBACK (time_out_end_configure), time_out); /* Basic dialog window setup */ gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-time-out-plugin"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); /* Create time settings section */ framebox = xfce_gtk_frame_box_new (_("Time settings"), &timebin); gtk_container_set_border_width (GTK_CONTAINER (framebox), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0); gtk_widget_show (framebox); /* Create time settings table */ table = gtk_table_new (3, 3, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_container_add (GTK_CONTAINER (timebin), table); gtk_widget_show (table); /* Create the labels for the minutes and seconds spins */ label = gtk_label_new (_("Minutes")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5); gtk_widget_show (label); label = gtk_label_new (_("Seconds")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1, GTK_SHRINK, GTK_FILL, 1.0, 0.5); gtk_widget_show (label); /* Create break countdown time label */ label = gtk_label_new (_("Time between breaks:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 1.0, 0.5); gtk_widget_show (label); /* Create break countdown time minute spin */ spin = gtk_spin_button_new_with_range (1, 24 * 60, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds / 60); gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); /* Store reference on the spin button in the plugin */ g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-minutes-spin", spin); /* Create break countdown time minute spin */ spin = gtk_spin_button_new_with_range (0, 59, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->break_countdown_seconds % 60); gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); /* Store reference on the spin button in the plugin */ g_object_set_data (G_OBJECT (time_out->plugin), "break-countdown-seconds-spin", spin); /* Create lock countdown time label */ label = gtk_label_new (_("Break length:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 1.0, 0.5); gtk_widget_show (label); /* Create lock countdown time spins */ spin = gtk_spin_button_new_with_range (0, 24 * 60, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds / 60); g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_minutes_changed), time_out); gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); spin = gtk_spin_button_new_with_range (0, 59, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->lock_countdown_seconds % 60); g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_lock_countdown_seconds_changed), time_out); gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); /* Create postpone countdown time label */ label = gtk_label_new (_("Postpone length:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 1.0, 0.5); gtk_widget_show (label); /* Create postpone countdown time spins */ spin = gtk_spin_button_new_with_range (0, 24 * 60, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds / 60); g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_minutes_changed), time_out); gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); spin = gtk_spin_button_new_with_range (0, 59, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time_out->postpone_countdown_seconds % 60); g_signal_connect (spin, "value-changed", G_CALLBACK (time_out_postpone_countdown_seconds_changed), time_out); gtk_table_attach (GTK_TABLE (table), spin, 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0.0, 0.5); gtk_widget_show (spin); /* Create behaviour section */ framebox = xfce_gtk_frame_box_new (_("Behaviour"), &behaviourbin); gtk_container_set_border_width (GTK_CONTAINER (framebox), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0); gtk_widget_show (framebox); /* Create behaviour box */ vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (behaviourbin), vbox); gtk_widget_show (vbox); /* Create postpone check button */ checkbutton = gtk_check_button_new_with_label (_("Allow postpone")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->allow_postpone); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_allow_postpone_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Create resume check button */ checkbutton = gtk_check_button_new_with_label (_("Resume automatically")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->auto_resume); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_auto_resume_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Create appearance section */ framebox = xfce_gtk_frame_box_new (_("Appearance"), &appearancebin); gtk_container_set_border_width (GTK_CONTAINER (framebox), 6); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), framebox, TRUE, TRUE, 0); gtk_widget_show (framebox); /* Create appearance box */ vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (appearancebin), vbox); gtk_widget_show (vbox); /* Create note label */ label = gtk_label_new(_("Note: Icon and time cannot be hidden simultaneously.")); gtk_container_add (GTK_CONTAINER (vbox), label); gtk_widget_show(label); /* Create display icon check button */ checkbutton = gtk_check_button_new_with_label (_("Display icon")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_icon); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_icon_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Create display time check button */ checkbutton = gtk_check_button_new_with_label (_("Display remaining time in the panel")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_time); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_time_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Create display hours check button */ checkbutton = gtk_check_button_new_with_label (_("Display hours")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_hours); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_hours_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Create display seconds check button */ checkbutton = gtk_check_button_new_with_label (_("Display seconds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), time_out->display_seconds); g_signal_connect (checkbutton, "toggled", G_CALLBACK (time_out_display_seconds_toggled), time_out); gtk_container_add (GTK_CONTAINER (vbox), checkbutton); gtk_widget_show (checkbutton); /* Show the entire dialog */ gtk_widget_show (dialog); }
void cb_image_uploaded (ScreenshooterJob *job, gchar *upload_name, gchar **last_user) { GtkWidget *dialog; GtkWidget *main_alignment, *vbox; GtkWidget *link_label; GtkWidget *image_link, *thumbnail_link, *small_thumbnail_link; GtkWidget *example_label, *html_label, *bb_label; GtkWidget *html_code_view, *bb_code_view; GtkWidget *html_frame, *bb_frame; GtkWidget *links_alignment, *code_alignment; GtkWidget *links_box, *code_box; GtkTextBuffer *html_buffer, *bb_buffer; const gchar *image_url, *thumbnail_url, *small_thumbnail_url; const gchar *image_markup, *thumbnail_markup, *small_thumbnail_markup; const gchar *html_code, *bb_code; gchar *job_type, *title; gchar *last_user_temp; g_return_if_fail (upload_name != NULL); job_type = g_object_get_data(G_OBJECT (job), "jobtype"); if (!strcmp(job_type, "imgur")) { title = _("My screenshot on Imgur"); image_url = g_strdup_printf ("http://i.imgur.com/%s.png", upload_name); thumbnail_url = g_strdup_printf ("http://imgur.com/%sl.png", upload_name); small_thumbnail_url = g_strdup_printf ("http://imgur.com/%ss.png", upload_name); } else { g_return_if_fail (last_user == NULL || *last_user == NULL); title = _("My screenshot on ZimageZ"); image_url = g_strdup_printf ("http://www.zimagez.com/zimage/%s.php", upload_name); thumbnail_url = g_strdup_printf ("http://www.zimagez.com/miniature/%s.php", upload_name); small_thumbnail_url = g_strdup_printf ("http://www.zimagez.com/avatar/%s.php", upload_name); last_user_temp = g_object_get_data (G_OBJECT (job), "user"); if (last_user_temp == NULL) last_user_temp = g_strdup (""); *last_user = g_strdup (last_user_temp); } image_markup = g_markup_printf_escaped (_("<a href=\"%s\">Full size image</a>"), image_url); thumbnail_markup = g_markup_printf_escaped (_("<a href=\"%s\">Large thumbnail</a>"), thumbnail_url); small_thumbnail_markup = g_markup_printf_escaped (_("<a href=\"%s\">Small thumbnail</a>"), small_thumbnail_url); html_code = g_markup_printf_escaped ("<a href=\"%s\">\n <img src=\"%s\" />\n</a>", image_url, thumbnail_url); bb_code = g_strdup_printf ("[url=%s]\n [img]%s[/img]\n[/url]", image_url, thumbnail_url); /* Dialog */ dialog = xfce_titled_dialog_new_with_buttons (title, NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 12); gtk_window_set_icon_name (GTK_WINDOW (dialog), "applications-internet"); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); /* Create the main alignment for the dialog */ main_alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 10, 10); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0); /* Create the main box for the dialog */ vbox = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_add (GTK_CONTAINER (main_alignment), vbox); /* Links bold label */ link_label = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL (link_label), _("<span weight=\"bold\" stretch=\"semiexpanded\">" "Links</span>")); gtk_misc_set_alignment (GTK_MISC (link_label), 0, 0); gtk_container_add (GTK_CONTAINER (vbox), link_label); /* Links alignment */ links_alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (links_alignment), 0, 0, 12, 0); gtk_container_add (GTK_CONTAINER (vbox), links_alignment); /* Links box */ links_box = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (links_box), 0); gtk_container_add (GTK_CONTAINER (links_alignment), links_box); /* Create the image link */ image_link = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (image_link), image_markup); gtk_misc_set_alignment (GTK_MISC (image_link), 0, 0); gtk_widget_set_tooltip_text (image_link, image_url); gtk_container_add (GTK_CONTAINER (links_box), image_link); /* Create the thumbnail link */ thumbnail_link = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (thumbnail_link), thumbnail_markup); gtk_misc_set_alignment (GTK_MISC (thumbnail_link), 0, 0); gtk_widget_set_tooltip_text (thumbnail_link, thumbnail_url); gtk_container_add (GTK_CONTAINER (links_box), thumbnail_link); /* Create the small thumbnail link */ small_thumbnail_link = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (small_thumbnail_link), small_thumbnail_markup); gtk_misc_set_alignment (GTK_MISC (small_thumbnail_link), 0, 0); gtk_widget_set_tooltip_text (small_thumbnail_link, small_thumbnail_url); gtk_container_add (GTK_CONTAINER (links_box), small_thumbnail_link); /* Examples bold label */ example_label = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL (example_label), _("<span weight=\"bold\" stretch=\"semiexpanded\">" "Code for a thumbnail pointing to the full size image</span>")); gtk_misc_set_alignment (GTK_MISC (example_label), 0, 0); gtk_container_add (GTK_CONTAINER (vbox), example_label); /* Code alignment */ code_alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (code_alignment), 0, 0, 12, 0); gtk_container_add (GTK_CONTAINER (vbox), code_alignment); /* Links box */ code_box = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (code_box), 0); gtk_container_add (GTK_CONTAINER (code_alignment), code_box); /* HTML title */ html_label = gtk_label_new (_("HTML")); gtk_misc_set_alignment (GTK_MISC (html_label), 0, 0); gtk_container_add (GTK_CONTAINER (code_box), html_label); /* HTML frame */ html_frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (html_frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (code_box), html_frame); /* HTML code text view */ html_buffer = gtk_text_buffer_new (NULL); gtk_text_buffer_set_text (html_buffer, html_code, -1); html_code_view = gtk_text_view_new_with_buffer (html_buffer); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (html_code_view), 10); gtk_text_view_set_editable (GTK_TEXT_VIEW (html_code_view), FALSE); gtk_container_add (GTK_CONTAINER (html_frame), html_code_view); /* BB title */ bb_label = gtk_label_new (_("BBCode for forums")); gtk_misc_set_alignment (GTK_MISC (bb_label), 0, 0); gtk_container_add (GTK_CONTAINER (code_box), bb_label); /* BB frame */ bb_frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (bb_frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (code_box), bb_frame); /* BBcode text view */ bb_buffer = gtk_text_buffer_new (NULL); gtk_text_buffer_set_text (bb_buffer, bb_code, -1); bb_code_view = gtk_text_view_new_with_buffer (bb_buffer); gtk_text_view_set_left_margin (GTK_TEXT_VIEW (bb_code_view), 10); gtk_text_view_set_editable (GTK_TEXT_VIEW (bb_code_view), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (bb_code_view), GTK_WRAP_CHAR); gtk_container_add (GTK_CONTAINER (bb_frame), bb_code_view); /* Show the dialog and run it */ gtk_widget_show_all (GTK_DIALOG(dialog)->vbox); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); g_object_unref (html_buffer); g_object_unref (bb_buffer); }
void cb_ask_for_information (ScreenshooterJob *job, GtkListStore *liststore, const gchar *message, gpointer unused) { GtkWidget *dialog; GtkWidget *information_label; GtkWidget *vbox, *main_alignment; GtkWidget *table; GtkWidget *user_entry, *password_entry, *title_entry, *comment_entry; GtkWidget *user_label, *password_label, *title_label, *comment_label; GtkTreeIter iter; gint response; g_return_if_fail (SCREENSHOOTER_IS_JOB (job)); g_return_if_fail (GTK_IS_LIST_STORE (liststore)); g_return_if_fail (message != NULL); TRACE ("Create the dialog to ask for user information."); /* Create the information dialog */ dialog = xfce_titled_dialog_new_with_buttons (_("Details about the screenshot for ZimageZ"), NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 12); gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info"); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); /* Create the main alignment for the dialog */ main_alignment = gtk_alignment_new (0, 0, 1, 1); gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 12, 12); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0); /* Create the main box for the dialog */ vbox = gtk_vbox_new (FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_container_add (GTK_CONTAINER (main_alignment), vbox); /* Create the information label */ information_label = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL (information_label), message); gtk_misc_set_alignment (GTK_MISC (information_label), 0, 0); gtk_container_add (GTK_CONTAINER (vbox), information_label); /* Create the layout table */ table = gtk_table_new (4, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 6); gtk_table_set_row_spacings (GTK_TABLE (table), 12); gtk_container_add (GTK_CONTAINER (vbox), table); /* Create the user label */ user_label = gtk_label_new (_("User:"******"Your Zimagez user name, if you do not have one yet" " please create one on the Web page linked above")); gtk_entry_set_activates_default (GTK_ENTRY (user_entry), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), user_entry, 1, 2, 0, 1); /* Create the password label */ password_label = gtk_label_new (_("Password:"******"The password for the user above")); gtk_entry_set_visibility (GTK_ENTRY (password_entry), FALSE); gtk_entry_set_activates_default (GTK_ENTRY (password_entry), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), password_entry, 1, 2, 1, 2); /* Create the title label */ title_label = gtk_label_new (_("Title:")); gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0.5); gtk_table_attach (GTK_TABLE (table), title_label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 0, 0); /* Create the title entry */ title_entry = gtk_entry_new (); gtk_widget_set_tooltip_text (title_entry, _("The title of the screenshot, it will be used when" " displaying the screenshot on ZimageZ")); gtk_entry_set_activates_default (GTK_ENTRY (title_entry), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), title_entry, 1, 2, 2, 3); /* Create the comment label */ comment_label = gtk_label_new (_("Comment:")); gtk_misc_set_alignment (GTK_MISC (comment_label), 0, 0.5); gtk_table_attach (GTK_TABLE (table), comment_label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 0, 0); /* Create the comment entry */ comment_entry = gtk_entry_new (); gtk_widget_set_tooltip_text (comment_entry, _("A comment on the screenshot, it will be used when" " displaying the screenshot on ZimageZ")); gtk_entry_set_activates_default (GTK_ENTRY (comment_entry), TRUE); gtk_table_attach_defaults (GTK_TABLE (table), comment_entry, 1, 2, 3, 4); /* Set the values */ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter); do { gint field_index; gchar *field_value = NULL; gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, 0, &field_index, 1, &field_value, -1); switch (field_index) { case USER: gtk_entry_set_text (GTK_ENTRY (user_entry), field_value); break; case PASSWORD: gtk_entry_set_text (GTK_ENTRY (password_entry), field_value); break; case TITLE: gtk_entry_set_text (GTK_ENTRY (title_entry), field_value); break; case COMMENT: gtk_entry_set_text (GTK_ENTRY (comment_entry), field_value); break; default: break; } g_free (field_value); } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter)); gtk_widget_show_all (GTK_DIALOG(dialog)->vbox); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_hide (dialog); if (response == GTK_RESPONSE_CANCEL || response == GTK_RESPONSE_DELETE_EVENT) { exo_job_cancel (EXO_JOB (job)); } else if (response == GTK_RESPONSE_OK) { gtk_tree_model_get_iter_first (GTK_TREE_MODEL (liststore), &iter); do { gint field_index; gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, 0, &field_index, -1); switch (field_index) { case USER: gtk_list_store_set (liststore, &iter, 1, gtk_entry_get_text (GTK_ENTRY (user_entry)), -1); break; case PASSWORD: gtk_list_store_set (liststore, &iter, 1, gtk_entry_get_text (GTK_ENTRY (password_entry)), -1); break; case TITLE: gtk_list_store_set (liststore, &iter, 1, gtk_entry_get_text (GTK_ENTRY (title_entry)), -1); break; case COMMENT: gtk_list_store_set (liststore, &iter, 1, gtk_entry_get_text (GTK_ENTRY (comment_entry)), -1); break; default: break; } } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (liststore), &iter)); } gtk_widget_destroy (dialog); }