static void panel_context_menu_create_new_panel (GtkWidget *menuitem) { panel_profile_create_toplevel (gtk_widget_get_screen (menuitem)); }
void gimp_display_shell_set_initial_scale (GimpDisplayShell *shell, gdouble scale, gint *display_width, gint *display_height) { GimpImage *image; GdkScreen *screen; gint image_width; gint image_height; gint shell_width; gint shell_height; gint screen_width; gint screen_height; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); image = gimp_display_get_image (shell->display); screen = gtk_widget_get_screen (GTK_WIDGET (shell)); image_width = gimp_image_get_width (image); image_height = gimp_image_get_height (image); screen_width = gdk_screen_get_width (screen) * 0.75; screen_height = gdk_screen_get_height (screen) * 0.75; /* We need to zoom before we use SCALE[XY] */ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, scale); shell_width = SCALEX (shell, image_width); shell_height = SCALEY (shell, image_height); if (shell->display->config->initial_zoom_to_fit) { /* Limit to the size of the screen... */ if (shell_width > screen_width || shell_height > screen_height) { gdouble new_scale; gdouble current = gimp_zoom_model_get_factor (shell->zoom); new_scale = current * MIN (((gdouble) screen_height) / shell_height, ((gdouble) screen_width) / shell_width); new_scale = gimp_zoom_model_zoom_step (GIMP_ZOOM_OUT, new_scale); /* Since zooming out might skip a zoom step we zoom in * again and test if we are small enough. */ gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, gimp_zoom_model_zoom_step (GIMP_ZOOM_IN, new_scale)); if (SCALEX (shell, image_width) > screen_width || SCALEY (shell, image_height) > screen_height) gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, new_scale); shell_width = SCALEX (shell, image_width); shell_height = SCALEY (shell, image_height); } } else { /* Set up size like above, but do not zoom to fit. Useful when * working on large images. */ if (shell_width > screen_width) shell_width = screen_width; if (shell_height > screen_height) shell_height = screen_height; } if (display_width) *display_width = shell_width; if (display_height) *display_height = shell_height; }
static void mateweather_pref_create(MateWeatherPref* pref) { GtkWidget* pref_vbox; GtkWidget* pref_notebook; #ifdef RADARMAP GtkWidget* radar_toggle_hbox; #endif /* RADARMAP */ GtkWidget* pref_basic_update_alignment; GtkWidget* pref_basic_update_lbl; GtkWidget* pref_basic_update_hbox; GtkObject* pref_basic_update_spin_adj; GtkWidget* pref_basic_update_sec_lbl; GtkWidget* pref_basic_note_lbl; GtkWidget* pref_loc_hbox; GtkWidget* pref_loc_note_lbl; GtkWidget* scrolled_window; GtkWidget* label; GtkWidget* value_hbox; GtkWidget* tree_label; GtkTreeSelection *selection; GtkWidget* pref_basic_vbox; GtkWidget* vbox; GtkWidget* frame; GtkWidget* temp_label; GtkWidget* temp_combo; GtkWidget* speed_label; GtkWidget* speed_combo; GtkWidget* pres_label; GtkWidget* pres_combo; GtkWidget* dist_label; GtkWidget* dist_combo; GtkWidget* unit_table; GtkWidget* pref_find_label; GtkWidget* pref_find_hbox; GtkWidget* image; g_object_set (pref, "destroy-with-parent", TRUE, NULL); gtk_window_set_title (GTK_WINDOW (pref), _("Weather Preferences")); gtk_dialog_add_buttons (GTK_DIALOG (pref), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, GTK_STOCK_HELP, GTK_RESPONSE_HELP, NULL); gtk_dialog_set_default_response (GTK_DIALOG (pref), GTK_RESPONSE_CLOSE); gtk_dialog_set_has_separator (GTK_DIALOG (pref), FALSE); gtk_container_set_border_width (GTK_CONTAINER (pref), 5); gtk_window_set_resizable (GTK_WINDOW (pref), TRUE); gtk_window_set_screen (GTK_WINDOW (pref), gtk_widget_get_screen (GTK_WIDGET (pref->priv->applet->applet))); pref_vbox = gtk_dialog_get_content_area (GTK_DIALOG (pref)); gtk_box_set_spacing (GTK_BOX (pref_vbox), 2); gtk_widget_show (pref_vbox); pref_notebook = gtk_notebook_new (); gtk_container_set_border_width (GTK_CONTAINER (pref_notebook), 5); gtk_widget_show (pref_notebook); gtk_box_pack_start (GTK_BOX (pref_vbox), pref_notebook, TRUE, TRUE, 0); /* * General settings page. */ pref_basic_vbox = gtk_vbox_new (FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (pref_basic_vbox), 12); gtk_container_add (GTK_CONTAINER (pref_notebook), pref_basic_vbox); pref_basic_update_alignment = gtk_alignment_new (0, 0.5, 0, 1); gtk_widget_show (pref_basic_update_alignment); pref->priv->basic_update_btn = gtk_check_button_new_with_mnemonic (_("_Automatically update every:")); gtk_widget_show (pref->priv->basic_update_btn); gtk_container_add (GTK_CONTAINER (pref_basic_update_alignment), pref->priv->basic_update_btn); g_signal_connect (G_OBJECT (pref->priv->basic_update_btn), "toggled", G_CALLBACK (auto_update_toggled), pref); if (!g_settings_is_writable (pref->priv->applet->settings, "auto-update")) { hard_set_sensitive (pref->priv->basic_update_btn, FALSE); } /* * Units settings page. */ /* Temperature Unit */ temp_label = gtk_label_new_with_mnemonic (_("_Temperature unit:")); gtk_label_set_use_markup (GTK_LABEL (temp_label), TRUE); gtk_label_set_justify (GTK_LABEL (temp_label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (temp_label), 0, 0.5); gtk_widget_show (temp_label); temp_combo = gtk_combo_box_new_text (); pref->priv->basic_temp_combo = temp_combo; gtk_label_set_mnemonic_widget (GTK_LABEL (temp_label), temp_combo); //gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Default")); gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Kelvin")); /* TRANSLATORS: Celsius is sometimes referred Centigrade */ gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Celsius")); gtk_combo_box_append_text (GTK_COMBO_BOX (temp_combo), _("Fahrenheit")); gtk_widget_show (temp_combo); if ( ! g_settings_is_writable (pref->priv->applet->settings, "temperature-unit")) { hard_set_sensitive (pref->priv->basic_temp_combo, FALSE); } /* Speed Unit */ speed_label = gtk_label_new_with_mnemonic (_("_Wind speed unit:")); gtk_label_set_use_markup (GTK_LABEL (speed_label), TRUE); gtk_label_set_justify (GTK_LABEL (speed_label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (speed_label), 0, 0.5); gtk_widget_show (speed_label); speed_combo = gtk_combo_box_new_text (); pref->priv->basic_speed_combo = speed_combo; gtk_label_set_mnemonic_widget (GTK_LABEL (speed_label), speed_combo); //gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("Default")); /* TRANSLATOR: The wind speed unit "meters per second" */ gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("m/s")); /* TRANSLATOR: The wind speed unit "kilometers per hour" */ gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("km/h")); /* TRANSLATOR: The wind speed unit "miles per hour" */ gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("mph")); /* TRANSLATOR: The wind speed unit "knots" */ gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("knots")); gtk_combo_box_append_text (GTK_COMBO_BOX (speed_combo), _("Beaufort scale")); gtk_widget_show (speed_combo); if (!g_settings_is_writable (pref->priv->applet->settings, "speed-unit")) { hard_set_sensitive (pref->priv->basic_speed_combo, FALSE); } /* Pressure Unit */ pres_label = gtk_label_new_with_mnemonic (_("_Pressure unit:")); gtk_label_set_use_markup (GTK_LABEL (pres_label), TRUE); gtk_label_set_justify (GTK_LABEL (pres_label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (pres_label), 0, 0.5); gtk_widget_show (pres_label); pres_combo = gtk_combo_box_new_text (); pref->priv->basic_pres_combo = pres_combo; gtk_label_set_mnemonic_widget (GTK_LABEL (pres_label), pres_combo); //gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("Default")); /* TRANSLATOR: The pressure unit "kiloPascals" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("kPa")); /* TRANSLATOR: The pressure unit "hectoPascals" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("hPa")); /* TRANSLATOR: The pressure unit "millibars" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("mb")); /* TRANSLATOR: The pressure unit "millibars of mercury" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("mmHg")); /* TRANSLATOR: The pressure unit "inches of mercury" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("inHg")); /* TRANSLATOR: The pressure unit "atmospheres" */ gtk_combo_box_append_text (GTK_COMBO_BOX (pres_combo), _("atm")); gtk_widget_show (pres_combo); if (!g_settings_is_writable(pref->priv->applet->settings, "pressure-unit")) { hard_set_sensitive(pref->priv->basic_pres_combo, FALSE); } /* Distance Unit */ dist_label = gtk_label_new_with_mnemonic (_("_Visibility unit:")); gtk_label_set_use_markup (GTK_LABEL (dist_label), TRUE); gtk_label_set_justify (GTK_LABEL (dist_label), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (dist_label), 0, 0.5); gtk_widget_show (dist_label); dist_combo = gtk_combo_box_new_text (); pref->priv->basic_dist_combo = dist_combo; gtk_label_set_mnemonic_widget (GTK_LABEL (dist_label), dist_combo); //gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("Default")); /* TRANSLATOR: The distance unit "meters" */ gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("meters")); /* TRANSLATOR: The distance unit "kilometers" */ gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("km")); /* TRANSLATOR: The distance unit "miles" */ gtk_combo_box_append_text (GTK_COMBO_BOX (dist_combo), _("miles")); gtk_widget_show (dist_combo); if ( ! g_settings_is_writable (pref->priv->applet->settings, "distance-unit")) hard_set_sensitive (pref->priv->basic_dist_combo, FALSE); unit_table = gtk_table_new(5, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(unit_table), 6); gtk_table_set_col_spacings(GTK_TABLE(unit_table), 12); gtk_table_attach(GTK_TABLE(unit_table), temp_label, 0, 1, 0, 1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_table_attach_defaults(GTK_TABLE(unit_table), temp_combo, 1, 2, 0, 1); gtk_table_attach(GTK_TABLE(unit_table), speed_label, 0, 1, 1, 2, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_table_attach_defaults(GTK_TABLE(unit_table), speed_combo, 1, 2, 1, 2); gtk_table_attach(GTK_TABLE(unit_table), pres_label, 0, 1, 2, 3, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_table_attach_defaults(GTK_TABLE(unit_table), pres_combo, 1, 2, 2, 3); gtk_table_attach(GTK_TABLE(unit_table), dist_label, 0, 1, 3, 4, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); gtk_table_attach_defaults(GTK_TABLE(unit_table), dist_combo, 1, 2, 3, 4); gtk_widget_show(unit_table); g_signal_connect (temp_combo, "changed", G_CALLBACK (temp_combo_changed_cb), pref); g_signal_connect (speed_combo, "changed", G_CALLBACK (speed_combo_changed_cb), pref); g_signal_connect (dist_combo, "changed", G_CALLBACK (dist_combo_changed_cb), pref); g_signal_connect (pres_combo, "changed", G_CALLBACK (pres_combo_changed_cb), pref); #ifdef RADARMAP pref->priv->basic_radar_btn = gtk_check_button_new_with_mnemonic (_("Enable _radar map")); gtk_widget_show (pref->priv->basic_radar_btn); g_signal_connect (G_OBJECT (pref->priv->basic_radar_btn), "toggled", G_CALLBACK (radar_toggled), pref); if (!g_settings_is_writable (pref->priv->applet->settings, "enable-radar-map")) { hard_set_sensitive(pref->priv->basic_radar_btn, FALSE); } radar_toggle_hbox = gtk_hbox_new(FALSE, 12); gtk_widget_show(radar_toggle_hbox); label = gtk_label_new (" "); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (radar_toggle_hbox), label, FALSE, FALSE, 0); pref->priv->basic_radar_url_btn = gtk_check_button_new_with_mnemonic (_("Use _custom address for radar map")); gtk_widget_show (pref->priv->basic_radar_url_btn); gtk_box_pack_start (GTK_BOX (radar_toggle_hbox), pref->priv->basic_radar_url_btn, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_btn), "toggled", G_CALLBACK (use_radar_url_toggled), pref); if ( ! g_settings_is_writable (pref->priv->applet->settings, "use-custom-radar-url")) { hard_set_sensitive (pref->priv->basic_radar_url_btn, FALSE); } pref->priv->basic_radar_url_hbox = gtk_hbox_new (FALSE, 12); gtk_widget_show (pref->priv->basic_radar_url_hbox); label = gtk_label_new (" "); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (pref->priv->basic_radar_url_hbox), label, FALSE, FALSE, 0); label = gtk_label_new_with_mnemonic (_("A_ddress:")); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (pref->priv->basic_radar_url_hbox), label, FALSE, FALSE, 0); pref->priv->basic_radar_url_entry = gtk_entry_new (); gtk_widget_show (pref->priv->basic_radar_url_entry); gtk_box_pack_start (GTK_BOX (pref->priv->basic_radar_url_hbox), pref->priv->basic_radar_url_entry, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (pref->priv->basic_radar_url_entry), "focus_out_event", G_CALLBACK (radar_url_changed), pref); if ( ! g_settings_is_writable (pref->priv->applet->settings, "radar")) { hard_set_sensitive (pref->priv->basic_radar_url_entry, FALSE); } #endif /* RADARMAP */ #ifdef HAVE_LIBNOTIFY /* setup show-notifications button */ pref->priv->basic_show_notifications_btn = gtk_check_button_new_with_mnemonic (_("Show _notifications")); if (!g_settings_is_writable (pref->priv->applet->settings, "show-notifications")) { hard_set_sensitive (pref->priv->basic_show_notifications_btn, FALSE); } g_signal_connect (G_OBJECT (pref->priv->basic_show_notifications_btn), "toggled", G_CALLBACK (show_notifications_toggled), pref); #endif frame = create_hig_catagory (pref_basic_vbox, _("Update")); pref_basic_update_hbox = gtk_hbox_new (FALSE, 12); pref_basic_update_lbl = gtk_label_new_with_mnemonic (_("_Automatically update every:")); gtk_widget_show (pref_basic_update_lbl); /* gtk_label_set_justify (GTK_LABEL (pref_basic_update_lbl), GTK_JUSTIFY_RIGHT); gtk_misc_set_alignment (GTK_MISC (pref_basic_update_lbl), 1, 0.5); */ gtk_widget_show (pref_basic_update_hbox); pref_basic_update_spin_adj = gtk_adjustment_new (30, 1, 3600, 5, 25, 1); pref->priv->basic_update_spin = gtk_spin_button_new (GTK_ADJUSTMENT (pref_basic_update_spin_adj), 1, 0); gtk_widget_show (pref->priv->basic_update_spin); gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (pref->priv->basic_update_spin), TRUE); gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (pref->priv->basic_update_spin), GTK_UPDATE_IF_VALID); g_signal_connect (G_OBJECT (pref->priv->basic_update_spin), "value_changed", G_CALLBACK (update_interval_changed), pref); pref_basic_update_sec_lbl = gtk_label_new (_("minutes")); gtk_widget_show (pref_basic_update_sec_lbl); if ( ! g_settings_is_writable (pref->priv->applet->settings, "auto-update-interval")) { hard_set_sensitive (pref->priv->basic_update_spin, FALSE); hard_set_sensitive (pref_basic_update_sec_lbl, FALSE); } value_hbox = gtk_hbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (pref_basic_update_hbox), pref_basic_update_alignment, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (pref_basic_update_hbox), value_hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (value_hbox), pref->priv->basic_update_spin, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (value_hbox), pref_basic_update_sec_lbl, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), pref_basic_update_hbox); frame = create_hig_catagory (pref_basic_vbox, _("Display")); vbox = gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), unit_table, TRUE, TRUE, 0); #ifdef RADARMAP gtk_box_pack_start (GTK_BOX (vbox), pref->priv->basic_radar_btn, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), radar_toggle_hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), pref->priv->basic_radar_url_hbox, TRUE, TRUE, 0); #endif /* RADARMAP */ #ifdef HAVE_LIBNOTIFY /* add the show-notification toggle button to the vbox of the display section */ gtk_box_pack_start (GTK_BOX (vbox), pref->priv->basic_show_notifications_btn, TRUE, TRUE, 0); #endif gtk_container_add (GTK_CONTAINER (frame), vbox); pref_basic_note_lbl = gtk_label_new (_("General")); gtk_widget_show (pref_basic_note_lbl); gtk_notebook_set_tab_label (GTK_NOTEBOOK (pref_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (pref_notebook), 0), pref_basic_note_lbl); /* * Location page. */ pref_loc_hbox = gtk_vbox_new (FALSE, 6); gtk_container_set_border_width (GTK_CONTAINER (pref_loc_hbox), 12); gtk_container_add (GTK_CONTAINER (pref_notebook), pref_loc_hbox); tree_label = gtk_label_new_with_mnemonic (_("_Select a location:")); gtk_misc_set_alignment (GTK_MISC (tree_label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (pref_loc_hbox), tree_label, FALSE, FALSE, 0); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); pref->priv->tree = gtk_tree_view_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (tree_label), GTK_WIDGET (pref->priv->tree)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pref->priv->tree), FALSE); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pref->priv->tree)); g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (row_selected_cb), pref); gtk_container_add (GTK_CONTAINER (scrolled_window), pref->priv->tree); gtk_widget_show (pref->priv->tree); gtk_widget_show (scrolled_window); gtk_box_pack_start (GTK_BOX (pref_loc_hbox), scrolled_window, TRUE, TRUE, 0); load_locations(pref); pref_find_hbox = gtk_hbox_new (FALSE, 6); pref_find_label = gtk_label_new (_("_Find:")); gtk_label_set_use_underline (GTK_LABEL (pref_find_label), TRUE); pref->priv->find_entry = gtk_entry_new (); gtk_label_set_mnemonic_widget (GTK_LABEL (pref_find_label), pref->priv->find_entry); pref->priv->find_next_btn = gtk_button_new_with_mnemonic (_("Find _Next")); gtk_widget_set_sensitive (pref->priv->find_next_btn, FALSE); image = gtk_image_new_from_stock (GTK_STOCK_FIND, GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (pref->priv->find_next_btn), image); g_signal_connect (G_OBJECT (pref->priv->find_next_btn), "clicked", G_CALLBACK (find_next_clicked), pref); g_signal_connect (G_OBJECT (pref->priv->find_entry), "changed", G_CALLBACK (find_entry_changed), pref); gtk_container_set_border_width (GTK_CONTAINER (pref_find_hbox), 0); gtk_box_pack_start (GTK_BOX (pref_find_hbox), pref_find_label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (pref_find_hbox), pref->priv->find_entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (pref_find_hbox), pref->priv->find_next_btn, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (pref_loc_hbox), pref_find_hbox, FALSE, FALSE, 0); if ( ! g_settings_is_writable (pref->priv->applet->settings, "location0")) { hard_set_sensitive (scrolled_window, FALSE); } pref_loc_note_lbl = gtk_label_new (_("Location")); gtk_widget_show (pref_loc_note_lbl); gtk_notebook_set_tab_label (GTK_NOTEBOOK (pref_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (pref_notebook), 1), pref_loc_note_lbl); g_signal_connect (G_OBJECT (pref), "response", G_CALLBACK (response_cb), pref); mateweather_pref_set_accessibility (pref); gtk_label_set_mnemonic_widget (GTK_LABEL (pref_basic_update_sec_lbl), pref->priv->basic_update_spin); gtk_label_set_mnemonic_widget (GTK_LABEL (label), pref->priv->basic_radar_url_entry); }
static void gtk_rotated_bin_realize (GtkWidget *widget) { GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); GtkAllocation allocation; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; guint border_width; GtkRequisition child_requisition; gtk_widget_set_realized (widget, TRUE); gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); attributes.x = allocation.x + border_width; attributes.y = allocation.y + border_width; attributes.width = allocation.width - 2 * border_width; attributes.height = allocation.height - 2 * border_width; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); g_signal_connect (window, "pick-embedded-child", G_CALLBACK (pick_offscreen_child), bin); attributes.window_type = GDK_WINDOW_OFFSCREEN; child_requisition.width = child_requisition.height = 0; if (bin->child && gtk_widget_get_visible (bin->child)) { GtkAllocation child_allocation; gtk_widget_get_allocation (bin->child, &child_allocation); attributes.width = child_allocation.width; attributes.height = child_allocation.height; } bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), &attributes, attributes_mask); gdk_window_set_user_data (bin->offscreen_window, widget); if (bin->child) gtk_widget_set_parent_window (bin->child, bin->offscreen_window); gdk_offscreen_window_set_embedder (bin->offscreen_window, window); g_signal_connect (bin->offscreen_window, "to-embedder", G_CALLBACK (offscreen_window_to_parent), bin); g_signal_connect (bin->offscreen_window, "from-embedder", G_CALLBACK (offscreen_window_from_parent), bin); gdk_window_show (bin->offscreen_window); }
/* Main program. */ int main(int argc, char * argv[]) { #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* Initialize GTK (via g_option_context_parse) and parse command line arguments. */ GOptionContext * context = g_option_context_new(""); g_option_context_add_main_entries(context, opt_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); GError * err = NULL; if ( ! g_option_context_parse(context, &argc, &argv, &err)) { g_print(_("Error: %s\n"), err->message); g_error_free(err); return 1; } g_option_context_free(context); HandlerContext handler_context; memset(&handler_context, 0, sizeof(handler_context)); /* Get the lxsession PID. */ const char * p = g_getenv("_LXSESSION_PID"); if (p != NULL) handler_context.lxsession_pid = atoi(p); /* Initialize capabilities of the systemd mechanism. */ if (dbus_systemd_CanPowerOff()) { handler_context.shutdown_available = TRUE; handler_context.shutdown_systemd = TRUE; } if (dbus_systemd_CanReboot()) { handler_context.reboot_available = TRUE; handler_context.reboot_systemd = TRUE; } if (dbus_systemd_CanSuspend()) { handler_context.suspend_available = TRUE; handler_context.suspend_systemd = TRUE; } if (dbus_systemd_CanHibernate()) { handler_context.hibernate_available = TRUE; handler_context.hibernate_systemd = TRUE; } /* Initialize capabilities of the ConsoleKit mechanism. */ if (!handler_context.shutdown_available && dbus_ConsoleKit_CanStop()) { handler_context.shutdown_available = TRUE; handler_context.shutdown_ConsoleKit = TRUE; } if (!handler_context.reboot_available && dbus_ConsoleKit_CanRestart()) { handler_context.reboot_available = TRUE; handler_context.reboot_ConsoleKit = TRUE; } /* Initialize capabilities of the UPower mechanism. */ if (!handler_context.suspend_available && dbus_UPower_CanSuspend()) { handler_context.suspend_available = TRUE; handler_context.suspend_UPower = TRUE; } if (!handler_context.hibernate_available && dbus_UPower_CanHibernate()) { handler_context.hibernate_available = TRUE; handler_context.hibernate_UPower = TRUE; } /* If we are under GDM, its "Switch User" is available. */ if (verify_running("gdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* If we are under GDM3, its "Switch User" is available. */ if (verify_running("gdm3", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm also use gdmflexiserver */ if (verify_running("lightdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm also use gdmflexiserver */ if (verify_running("lightdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm can also be find by the env */ if (g_getenv("XDG_SEAT_PATH")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_LIGHTDM = TRUE; } /* If we are under KDM, its "Switch User" is available. */ if (verify_running("kdm", "kdmctl")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_KDM = TRUE; } if (verify_running("lxdm", "lxdm-binary")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_LXDM = TRUE; } /* LTSP support */ if (g_getenv("LTSP_CLIENT")) { handler_context.ltsp = TRUE; handler_context.shutdown_available = TRUE; handler_context.reboot_available = TRUE; } /* Lock screen */ const gchar* very_lock_screen = determine_lock_screen(); if (very_lock_screen) { handler_context.lock_screen = TRUE; } /* Make the button images accessible. */ gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/lxsession/images"); /* Get the background pixbuf. */ GdkPixbuf * pixbuf = get_background_pixbuf(); /* Create the toplevel window. */ GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_fullscreen(GTK_WINDOW(window)); GdkScreen* screen = gtk_widget_get_screen(window); gtk_window_set_default_size(GTK_WINDOW(window), gdk_screen_get_width(screen), gdk_screen_get_height(screen)); gtk_widget_set_app_paintable(window, TRUE); g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(expose_event), pixbuf); /* Toplevel container */ GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); gtk_container_add(GTK_CONTAINER(window), alignment); GtkWidget* center_area = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(alignment), center_area); GtkWidget* center_vbox = gtk_vbox_new(FALSE, 6); gtk_container_set_border_width(GTK_CONTAINER(center_vbox), 12); gtk_container_add(GTK_CONTAINER(center_area), center_vbox); GtkWidget* controls = gtk_vbox_new(FALSE, 6); /* If specified, apply a user-specified banner image. */ if (banner_path != NULL) { GtkWidget * banner_image = gtk_image_new_from_file(banner_path); GtkPositionType banner_position = get_banner_position(); switch (banner_position) { case GTK_POS_LEFT: case GTK_POS_RIGHT: { /* Create a horizontal box to contain the image and the controls. */ GtkWidget * box = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), box, FALSE, FALSE, 0); /* Pack the image and a separator. */ gtk_misc_set_alignment(GTK_MISC(banner_image), 0.5, 0.0); if (banner_position == GTK_POS_LEFT) { gtk_box_pack_start(GTK_BOX(box), banner_image, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2); } else { gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(box), banner_image, FALSE, FALSE, 2); } } break; case GTK_POS_TOP: gtk_box_pack_start(GTK_BOX(controls), banner_image, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); break; case GTK_POS_BOTTOM: gtk_box_pack_end(GTK_BOX(controls), banner_image, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); break; } } else gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); /* Create the label. */ GtkWidget * label = gtk_label_new(""); if (prompt == NULL) { const char * session_name = g_getenv("DESKTOP_SESSION"); if (session_name == NULL) session_name = "LXDE"; const gchar *command_line = "lsb_release -r -s"; gchar *output = NULL; GError *error; if (!g_spawn_command_line_sync( command_line, &output, NULL, NULL, &error)) { fprintf (stderr, "Error: %s\n", error->message); g_error_free (error); } if (output == NULL) { output = ""; } else { output[strlen ( output ) - 1] = '\0'; } prompt = g_strdup_printf(_("<b><big>Logout %s %s session ?</big></b>"), session_name, output); } gtk_label_set_markup(GTK_LABEL(label), prompt); gtk_box_pack_start(GTK_BOX(controls), label, FALSE, FALSE, 4); /* Create the Shutdown button. */ if (handler_context.shutdown_available) { GtkWidget * shutdown_button = gtk_button_new_with_mnemonic(_("Sh_utdown")); GtkWidget * image = gtk_image_new_from_icon_name("system-shutdown", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(shutdown_button), image); gtk_button_set_alignment(GTK_BUTTON(shutdown_button), 0.0, 0.5); g_signal_connect(G_OBJECT(shutdown_button), "clicked", G_CALLBACK(shutdown_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), shutdown_button, FALSE, FALSE, 4); } /* Create the Reboot button. */ if (handler_context.reboot_available) { GtkWidget * reboot_button = gtk_button_new_with_mnemonic(_("_Reboot")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-reboot", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(reboot_button), image); gtk_button_set_alignment(GTK_BUTTON(reboot_button), 0.0, 0.5); g_signal_connect(G_OBJECT(reboot_button), "clicked", G_CALLBACK(reboot_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), reboot_button, FALSE, FALSE, 4); } /* Create the Suspend button. */ if (handler_context.suspend_available && !handler_context.ltsp) { GtkWidget * suspend_button = gtk_button_new_with_mnemonic(_("_Suspend")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-suspend", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(suspend_button), image); gtk_button_set_alignment(GTK_BUTTON(suspend_button), 0.0, 0.5); g_signal_connect(G_OBJECT(suspend_button), "clicked", G_CALLBACK(suspend_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), suspend_button, FALSE, FALSE, 4); } /* Create the Hibernate button. */ if (handler_context.hibernate_available && !handler_context.ltsp) { GtkWidget * hibernate_button = gtk_button_new_with_mnemonic(_("_Hibernate")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-hibernate", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(hibernate_button), image); gtk_button_set_alignment(GTK_BUTTON(hibernate_button), 0.0, 0.5); g_signal_connect(G_OBJECT(hibernate_button), "clicked", G_CALLBACK(hibernate_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), hibernate_button, FALSE, FALSE, 4); } /* Create the Switch User button. */ if (handler_context.switch_user_available && !handler_context.ltsp) { GtkWidget * switch_user_button = gtk_button_new_with_mnemonic(_("S_witch User")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-switch", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(switch_user_button), image); gtk_button_set_alignment(GTK_BUTTON(switch_user_button), 0.0, 0.5); g_signal_connect(G_OBJECT(switch_user_button), "clicked", G_CALLBACK(switch_user_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), switch_user_button, FALSE, FALSE, 4); } /* Create the Lock Screen button. */ if (handler_context.lock_screen && !handler_context.ltsp) { GtkWidget * lock_screen_button = gtk_button_new_with_mnemonic(_("L_ock Screen")); GtkWidget * image = gtk_image_new_from_icon_name("system-lock-screen", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(lock_screen_button), image); gtk_button_set_alignment(GTK_BUTTON(lock_screen_button), 0.0, 0.5); g_signal_connect(G_OBJECT(lock_screen_button), "clicked", G_CALLBACK(lock_screen_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), lock_screen_button, FALSE, FALSE, 4); } /* Create the Logout button. */ GtkWidget * logout_button = gtk_button_new_with_mnemonic(_("_Logout")); GtkWidget * image = gtk_image_new_from_icon_name("system-log-out", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(logout_button), image); gtk_button_set_alignment(GTK_BUTTON(logout_button), 0.0, 0.5); g_signal_connect(G_OBJECT(logout_button), "clicked", G_CALLBACK(logout_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), logout_button, FALSE, FALSE, 4); /* Create the Cancel button. */ GtkWidget * cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_button_set_alignment(GTK_BUTTON(cancel_button), 0.0, 0.5); g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(cancel_clicked), NULL); gtk_box_pack_start(GTK_BOX(controls), cancel_button, FALSE, FALSE, 4); /* Create the error text. */ handler_context.error_label = gtk_label_new(""); gtk_label_set_justify(GTK_LABEL(handler_context.error_label), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(controls), handler_context.error_label, FALSE, FALSE, 4); /* Show everything. */ gtk_widget_show_all(window); /* Run the main event loop. */ gtk_main(); /* Return. */ return 0; }
bool wxTopLevelWindowGTK::Show( bool show ) { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); #ifdef GDK_WINDOWING_X11 bool deferShow = show && !m_isShown && m_deferShow; if (deferShow) { deferShow = m_deferShowAllowed && gs_requestFrameExtentsStatus != 2 && !gtk_widget_get_realized(m_widget) && g_signal_handler_find(m_widget, GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET), 0, NULL, NULL, this); if (deferShow) { GdkScreen* screen = gtk_widget_get_screen(m_widget); GdkAtom atom = gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false); deferShow = gdk_x11_screen_supports_net_wm_hint(screen, atom) != 0; // If _NET_REQUEST_FRAME_EXTENTS not supported, don't allow changes // to m_decorSize, it breaks saving/restoring window size with // GetSize()/SetSize() because it makes window bigger between each // restore and save. m_updateDecorSize = deferShow; } m_deferShow = deferShow; } if (deferShow) { // Initial show. If WM supports _NET_REQUEST_FRAME_EXTENTS, defer // calling gtk_widget_show() until _NET_FRAME_EXTENTS property // notification is received, so correct frame extents are known. // This allows resizing m_widget to keep the overall size in sync with // what wxWidgets expects it to be without an obvious change in the // window size immediately after it becomes visible. // Realize m_widget, so m_widget->window can be used. Realizing normally // causes the widget tree to be size_allocated, which generates size // events in the wrong order. However, the size_allocates will not be // done if the allocation is not the default (1,1). GtkAllocation alloc; gtk_widget_get_allocation(m_widget, &alloc); const int alloc_width = alloc.width; if (alloc_width == 1) { alloc.width = 2; gtk_widget_set_allocation(m_widget, &alloc); } gtk_widget_realize(m_widget); if (alloc_width == 1) { alloc.width = 1; gtk_widget_set_allocation(m_widget, &alloc); } // send _NET_REQUEST_FRAME_EXTENTS XClientMessageEvent xevent; memset(&xevent, 0, sizeof(xevent)); xevent.type = ClientMessage; GdkWindow* window = gtk_widget_get_window(m_widget); xevent.window = GDK_WINDOW_XID(window); xevent.message_type = gdk_x11_atom_to_xatom_for_display( gdk_window_get_display(window), gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false)); xevent.format = 32; Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window)); XSendEvent(display, DefaultRootWindow(display), false, SubstructureNotifyMask | SubstructureRedirectMask, (XEvent*)&xevent); if (gs_requestFrameExtentsStatus == 0) { // if WM does not respond to request within 1 second, // we assume support for _NET_REQUEST_FRAME_EXTENTS is not working m_netFrameExtentsTimerId = g_timeout_add(1000, request_frame_extents_timeout, this); } // defer calling gtk_widget_show() m_isShown = true; return true; } #endif // GDK_WINDOWING_X11 if (show && !gtk_widget_get_realized(m_widget)) { // size_allocate signals occur in reverse order (bottom to top). // Things work better if the initial wxSizeEvents are sent (from the // top down), before the initial size_allocate signals occur. wxSizeEvent event(GetSize(), GetId()); event.SetEventObject(this); HandleWindowEvent(event); } bool change = base_type::Show(show); if (change && !show) { // make sure window has a non-default position, so when it is shown // again, it won't be repositioned by WM as if it were a new window // Note that this must be done _after_ the window is hidden. gtk_window_move((GtkWindow*)m_widget, m_x, m_y); } return change; }
static void popup_add_note (StickyNotesApplet *applet, GtkWidget *item) { stickynotes_add (gtk_widget_get_screen (applet->w_applet)); }
static gboolean confirm_delete_immediately (GtkWidget *parent_view, gint num_files, gboolean all) { GdkScreen *screen; GtkWidget *dialog, *hbox, *vbox, *image, *label; gchar *str, *prompt, *detail; int response; screen = gtk_widget_get_screen (parent_view); dialog = gtk_dialog_new (); gtk_window_set_screen (GTK_WINDOW (dialog), screen); atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT); gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Immediately?")); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_widget_realize (dialog); gdk_window_set_transient_for (gtk_widget_get_window (GTK_WIDGET (dialog)), gdk_screen_get_root_window (screen)); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, FALSE, FALSE, 0); image = gtk_image_new_from_icon_name ("dialog-question", GTK_ICON_SIZE_DIALOG); gtk_widget_set_halign (image, GTK_ALIGN_CENTER); gtk_widget_set_valign (image, GTK_ALIGN_START); gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); if (all) { prompt = _("Cannot move items to trash, do you want to delete them immediately?"); detail = g_strdup_printf ("None of the %d selected items can be moved to the Trash", num_files); } else { prompt = _("Cannot move some items to trash, do you want to delete these immediately?"); detail = g_strdup_printf ("%d of the selected items cannot be moved to the Trash", num_files); } str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", prompt, "</span>", NULL); label = gtk_label_new (str); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (str); label = gtk_label_new (detail); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_xalign (GTK_LABEL (label), 0.0); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_widget_show (label); g_free (detail); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel"), GTK_RESPONSE_CANCEL); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Delete"), GTK_RESPONSE_YES); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog)); return response == GTK_RESPONSE_YES; }
static VALUE rg_screen(VALUE self) { return GOBJ2RVAL(gtk_widget_get_screen(_SELF(self))); }
MetaWindowMenu* meta_window_menu_new (MetaFrames *frames, MetaMenuOp ops, MetaMenuOp insensitive, Window client_xwindow, unsigned long active_workspace, int n_workspaces, MetaWindowMenuFunc func, gpointer data) { int i; MetaWindowMenu *menu; /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */ if (n_workspaces < 2) ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES); else if (n_workspaces == 2) /* #151183: If we only have two workspaces, disable the menu listing them. */ ops &= ~(META_MENU_OP_WORKSPACES); menu = g_new (MetaWindowMenu, 1); menu->frames = frames; menu->client_xwindow = client_xwindow; menu->func = func; menu->data = data; menu->ops = ops; menu->insensitive = insensitive; menu->menu = gtk_menu_new (); gtk_menu_set_screen (GTK_MENU (menu->menu), gtk_widget_get_screen (GTK_WIDGET (frames))); for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++) { MenuItem menuitem = menuitems[i]; if (ops & menuitem.op || menuitem.op == 0) { GtkWidget *mi; MenuData *md; unsigned int key; MetaVirtualModifier mods; mi = menu_item_new (&menuitem, -1); /* Set the activeness of radiobuttons. */ switch (menuitem.op) { case META_MENU_OP_STICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace == 0xFFFFFFFF); break; case META_MENU_OP_UNSTICK: gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi), active_workspace != 0xFFFFFFFF); break; default: break; } if (menuitem.type == MENU_ITEM_WORKSPACE_LIST) { if (ops & META_MENU_OP_WORKSPACES) { Display *display; Window xroot; GdkScreen *screen; GtkWidget *submenu; int j; MenuItem to_another_workspace = { 0, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Another _Workspace") }; meta_verbose ("Creating %d-workspace menu current space %lu\n", n_workspaces, active_workspace); display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window); screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window); xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen)); submenu = gtk_menu_new (); g_assert (mi==NULL); mi = menu_item_new (&to_another_workspace, -1); gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu); for (j = 0; j < n_workspaces; j++) { char *label; MenuData *md; unsigned int key; MetaVirtualModifier mods; MenuItem moveitem; GtkWidget *submi; meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES, j + 1, &key, &mods); label = get_workspace_name_with_accel (display, xroot, j); moveitem.type = MENU_ITEM_NORMAL; moveitem.op = META_MENU_OP_WORKSPACES; moveitem.label = label; submi = menu_item_new (&moveitem, j + 1); g_free (label); if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK)) gtk_widget_set_sensitive (submi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = META_MENU_OP_WORKSPACES; g_object_set_data (G_OBJECT (submi), "workspace", GINT_TO_POINTER (j)); gtk_signal_connect_full (GTK_OBJECT (submi), "activate", G_CALLBACK (activate_cb), NULL, md, g_free, FALSE, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi); gtk_widget_show (submi); } } else meta_verbose ("not creating workspace menu\n"); } else if (menuitem.type != MENU_ITEM_SEPARATOR) { meta_core_get_menu_accelerator (menuitems[i].op, -1, &key, &mods); if (insensitive & menuitem.op) gtk_widget_set_sensitive (mi, FALSE); md = g_new (MenuData, 1); md->menu = menu; md->op = menuitem.op; gtk_signal_connect_full (GTK_OBJECT (mi), "activate", G_CALLBACK (activate_cb), NULL, md, g_free, FALSE, FALSE); } if (mi) { gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi); gtk_widget_show (mi); } } } g_signal_connect (menu->menu, "selection_done", G_CALLBACK(menu_closed), menu); return menu; }
void awn_applet_proxy_execute (AwnAppletProxy *proxy) { AwnAppletProxyPrivate *priv; GdkScreen *screen; GError *error = NULL; gint panel_id = AWN_PANEL_ID_DEFAULT; gchar *exec; gchar **argv = NULL; GPid pid; GSpawnFlags flags = G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD; priv = AWN_APPLET_PROXY_GET_PRIVATE (proxy); priv->size_req_initialized = FALSE; gtk_widget_realize (GTK_WIDGET (proxy)); /* FIXME: update tooltip with name of the applet?! */ /* Load the applet */ screen = gtk_widget_get_screen (GTK_WIDGET (proxy)); gint64 socket_id = (gint64) gtk_socket_get_id (GTK_SOCKET (proxy)); g_object_get (G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET (proxy))), "panel-id", &panel_id, NULL); if (g_getenv ("AWN_APPLET_GDB")) { exec = g_strdup_printf (DEBUG_APPLET_EXEC, priv->path, priv->uid, socket_id, panel_id); } else { exec = g_strdup_printf (APPLET_EXEC, priv->path, priv->uid, socket_id, panel_id); } g_shell_parse_argv (exec, NULL, &argv, &error); g_warn_if_fail (error == NULL); if (gdk_spawn_on_screen ( screen, NULL, argv, NULL, flags, NULL, NULL, &pid, &error)) { priv->running = TRUE; g_child_watch_add(pid, on_child_exit, proxy); gchar *desktop = g_path_get_basename (priv->path); g_debug ("Spawned awn-applet[%d] for \"%s\", UID: %s, XID: %" G_GINT64_FORMAT, pid, desktop, priv->uid, socket_id); g_free (desktop); } else { g_warning ("Unable to load applet %s: %s", priv->path, error->message); g_error_free (error); g_signal_emit (proxy, _proxy_signals[APPLET_CRASHED], 0); } g_strfreev (argv); g_free (exec); }
void budgie_popover_present(BudgiePopover *self, GtkWidget *parent, GdkEventButton *event) { GtkWidget *real_parent; GdkWindow *parent_window; gint x, y, tx, ty, rx, margin; GdkScreen *screen; GtkAllocation alloc, our_alloc; GdkDeviceManager *manager; gint32 time; if (event) { x = event->x; y = event->y; } if (gtk_widget_get_visible(GTK_WIDGET(self))) { budgie_popover_hide(self); return; } if (!gtk_widget_get_realized(GTK_WIDGET(self))) gtk_widget_realize(GTK_WIDGET(self)); /* Get position of parent widget on screen */ real_parent = gtk_widget_get_toplevel(parent); parent_window = gtk_widget_get_window(real_parent); gdk_window_get_position(parent_window, &x, &y); gtk_widget_translate_coordinates(parent, real_parent, x, y, &tx, &ty); gtk_widget_get_allocation(parent, &alloc); gtk_widget_get_allocation(GTK_WIDGET(self), &our_alloc); screen = gtk_widget_get_screen(GTK_WIDGET(self)); /* Ensure we're in a sensible position (under/over) */ if (ty + our_alloc.height + 11 < gdk_screen_get_height(screen)) { self->top = TRUE; ty = y+alloc.y+alloc.height; } else { ty = (y+alloc.y)-our_alloc.height; self->top = FALSE; } /* Ensure widg_x is within bounds */ if (event) { /* Point tip to mouse x,y */ rx = event->x; } else { /* Center the tip when there is no event */ rx = alloc.x + (alloc.width/2); } /* ensure margin is accounted for */ g_object_get(parent, "margin", &margin, NULL); tx -= margin; rx -= margin; if (rx >= our_alloc.width) rx = our_alloc.width - 18; if (rx <= 18) rx = 18; self->widg_x = rx; gtk_window_move(GTK_WINDOW(self), tx-11, ty); gtk_widget_show_all(GTK_WIDGET(self)); if (event) { self->pointer = event->device; time = event->time; } else { manager = gdk_display_get_device_manager(gdk_screen_get_display(screen)); self->pointer = gdk_device_manager_get_client_pointer(manager); time = GDK_CURRENT_TIME; } self->parent_widget = real_parent; self->con_id = g_signal_connect(real_parent, "button-press-event", G_CALLBACK(button_press), self); self->con_id = 0; /* TODO: Handle keyboard grab too */ popup_grab_on_window(gtk_widget_get_window(GTK_WIDGET(real_parent)), NULL, self->pointer, time); }
static void hn_others_button_get_menu_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, GtkWidget *button) { GtkRequisition req; GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(menu)); int menu_height = 0; int main_height = 0; GtkAllocation workarea = { 0, 0, 0, 0 }; GtkWidget *top_level; HildonDesktopPanelWindowOrientation orientation = HILDON_DESKTOP_PANEL_WINDOW_ORIENTATION_LEFT; hn_others_button_get_workarea (&workarea); *push_in = FALSE; top_level = gtk_widget_get_toplevel (button); if (HILDON_DESKTOP_IS_PANEL_WINDOW (top_level)) { g_object_get (top_level, "orientation", &orientation, NULL); } gtk_widget_size_request (GTK_WIDGET (menu), &req); menu_height = req.height; main_height = gdk_screen_get_height (screen); switch (orientation) { case HILDON_DESKTOP_PANEL_WINDOW_ORIENTATION_LEFT: *x = workarea.x; if (main_height - button->allocation.y < menu_height) *y = MAX(0, ((main_height - menu_height) / 2)); else *y = button->allocation.y; break; case HILDON_DESKTOP_PANEL_WINDOW_ORIENTATION_RIGHT: *x = workarea.x + workarea.width - req.width; if (main_height - button->allocation.y < menu_height) *y = MAX(0, ((main_height - menu_height) / 2)); else *y = button->allocation.y; break; case HILDON_DESKTOP_PANEL_WINDOW_ORIENTATION_TOP: *x = button->allocation.x; *y = workarea.y; break; case HILDON_DESKTOP_PANEL_WINDOW_ORIENTATION_BOTTOM: *x = button->allocation.x; *y = workarea.y + workarea.height - req.height; break; default: g_assert_not_reached (); } }
static void applet_realized (PanelApplet *applet, TasklistData *tasklist) { tasklist->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (tasklist->applet)); }
/* Force Quit */ static void panel_action_force_quit (GtkWidget *widget) { panel_force_quit (gtk_widget_get_screen (widget), gtk_get_current_event_time ()); }
GtkWidget * do_tree_store (GtkWidget *do_widget) { if (!window) { GtkWidget *vbox; GtkWidget *sw; GtkWidget *treeview; GtkTreeModel *model; /* create window, etc */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Card planning sheet"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); vbox = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Jonathan's Holiday Card Planning Sheet"), FALSE, FALSE, 0); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); /* create model */ model = create_model (); /* create tree view */ treeview = gtk_tree_view_new_with_model (model); g_object_unref (model); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)), GTK_SELECTION_MULTIPLE); add_columns (GTK_TREE_VIEW (treeview)); gtk_container_add (GTK_CONTAINER (sw), treeview); /* expand all rows after the treeview widget has been realized */ g_signal_connect (treeview, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); gtk_window_set_default_size (GTK_WINDOW (window), 650, 400); } if (!GTK_WIDGET_VISIBLE (window)) gtk_widget_show_all (window); else { gtk_widget_destroy (window); window = NULL; } return window; }
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long) { if (show == m_fsIsShowing) return false; // return what? m_fsIsShowing = show; #ifdef GDK_WINDOWING_X11 Display* xdpy = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(m_widget)); Window xroot = GDK_WINDOW_XID(gtk_widget_get_root_window(m_widget)); wxX11FullScreenMethod method = wxGetFullScreenMethodX11(xdpy, (WXWindow)xroot); // NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions // to switch to fullscreen, which is not always available. We must // check if WM supports the spec and use legacy methods if it // doesn't. if ( method == wxX11_FS_WMSPEC ) #endif // GDK_WINDOWING_X11 { if (show) gtk_window_fullscreen( GTK_WINDOW( m_widget ) ); else gtk_window_unfullscreen( GTK_WINDOW( m_widget ) ); } #ifdef GDK_WINDOWING_X11 else { GdkWindow* window = gtk_widget_get_window(m_widget); Window xid = GDK_WINDOW_XID(window); if (show) { GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y ); GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height ); GdkScreen* screen = gtk_widget_get_screen(m_widget); const int screen_width = gdk_screen_get_width(screen); const int screen_height = gdk_screen_get_height(screen); gint client_x, client_y, root_x, root_y; gint width, height; m_fsSaveGdkFunc = m_gdkFunc; m_fsSaveGdkDecor = m_gdkDecor; m_gdkFunc = m_gdkDecor = 0; gdk_window_set_decorations(window, (GdkWMDecoration)0); gdk_window_set_functions(window, (GdkWMFunction)0); gdk_window_get_origin(window, &root_x, &root_y); gdk_window_get_geometry(window, &client_x, &client_y, &width, &height); gdk_window_move_resize( window, -client_x, -client_y, screen_width + 1, screen_height + 1); wxSetFullScreenStateX11(xdpy, (WXWindow)xroot, (WXWindow)xid, show, &m_fsSaveFrame, method); } else // hide { m_gdkFunc = m_fsSaveGdkFunc; m_gdkDecor = m_fsSaveGdkDecor; gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor); gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc); wxSetFullScreenStateX11(xdpy, (WXWindow)xroot, (WXWindow)xid, show, &m_fsSaveFrame, method); SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height); } } #endif // GDK_WINDOWING_X11 // documented behaviour is to show the window if it's still hidden when // showing it full screen if (show) Show(); return true; }
static void run_cc_cb (G_GNUC_UNUSED GtkButton *button, GdauiLogin *login) { gboolean sresult = FALSE; GError *lerror = NULL; gchar *cmd; /* run gda-control-center tool */ #ifdef G_OS_WIN32 #define EXENAME "gda-control-center-" GDA_ABI_VERSION ".exe" gchar *argv[] = {EXENAME, NULL}; cmd = gda_gbr_get_file_path (GDA_BIN_DIR, NULL); sresult = g_spawn_async (cmd, argv, NULL, 0, NULL, NULL, NULL, &lerror); g_free (cmd); #else #define EXENAME "gda-control-center-" GDA_ABI_VERSION GAppInfo *appinfo; GdkAppLaunchContext *context; GdkScreen *screen; cmd = gda_gbr_get_file_path (GDA_BIN_DIR, (char *) EXENAME, NULL); appinfo = g_app_info_create_from_commandline (cmd, NULL, G_APP_INFO_CREATE_NONE, &lerror); g_free (cmd); if (!appinfo) goto checkerror; screen = gtk_widget_get_screen (GTK_WIDGET (login)); context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen)); gdk_app_launch_context_set_screen (context, screen); sresult = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), NULL); if (! sresult) { g_object_unref (appinfo); appinfo = g_app_info_create_from_commandline (EXENAME, NULL, G_APP_INFO_CREATE_NONE, NULL); if (!appinfo) { g_object_unref (context); goto checkerror; } sresult = g_app_info_launch (appinfo, NULL, G_APP_LAUNCH_CONTEXT (context), &lerror); } g_object_unref (context); g_object_unref (appinfo); #endif /* G_OS_WIN32 */ checkerror: if (!sresult) { GtkWidget *msgdialog; GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (login)); if (!gtk_widget_is_toplevel (toplevel)) toplevel = NULL; msgdialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (toplevel), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "<b>%s:</b>\n%s", _("Could not execute the Database access control center"), lerror && lerror->message ? lerror->message : _("No detail")); if (lerror) g_error_free (lerror); gtk_dialog_run (GTK_DIALOG (msgdialog)); gtk_widget_destroy (msgdialog); } }
/* Menu Callback : Configure preferences */ void menu_preferences_cb(GtkAction *action, StickyNotesApplet *applet) { stickynotes_applet_update_prefs(); gtk_window_set_screen(GTK_WINDOW(stickynotes->w_prefs), gtk_widget_get_screen(applet->w_applet)); gtk_window_present(GTK_WINDOW(stickynotes->w_prefs)); }
static void file_open_location_response (GtkDialog *dialog, gint response_id, Gimp *gimp) { GtkWidget *entry; GtkWidget *box; const gchar *text = NULL; if (response_id != GTK_RESPONSE_OK) { box = g_object_get_data (G_OBJECT (dialog), "progress-box"); if (box && GIMP_PROGRESS_BOX (box)->active) gimp_progress_cancel (GIMP_PROGRESS (box)); else gtk_widget_destroy (GTK_WIDGET (dialog)); return; } entry = g_object_get_data (G_OBJECT (dialog), "location-entry"); gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE); gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, FALSE); text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text && strlen (text)) { GimpImage *image; gchar *filename; GFile *file; GimpPDBStatusType status; GError *error = NULL; filename = g_filename_from_uri (text, NULL, NULL); if (filename) { file = g_file_new_for_uri (text); g_free (filename); } else { file = file_utils_filename_to_file (gimp, text, &error); } box = gimp_progress_box_new (); gtk_container_set_border_width (GTK_CONTAINER (box), 12); gtk_box_pack_end (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), box, FALSE, FALSE, 0); g_object_set_data (G_OBJECT (dialog), "progress-box", box); if (file) { GFile *entered_file = g_file_new_for_uri (text); gtk_widget_show (box); image = file_open_with_proc_and_display (gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (box), file, entered_file, FALSE, NULL, G_OBJECT (gtk_widget_get_screen (entry)), gimp_widget_get_monitor (entry), &status, &error); g_object_unref (entered_file); if (image == NULL && status != GIMP_PDB_CANCEL) { gimp_message (gimp, G_OBJECT (box), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), gimp_file_get_utf8_name (file), error->message); g_clear_error (&error); } g_object_unref (file); } else { gimp_message (gimp, G_OBJECT (box), GIMP_MESSAGE_ERROR, _("Opening '%s' failed:\n\n%s"), text, error->message); g_clear_error (&error); gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, TRUE); gtk_editable_set_editable (GTK_EDITABLE (entry), TRUE); return; } } gtk_widget_destroy (GTK_WIDGET (dialog)); }
void gradients_save_as_pov_ray_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContext *context; GimpGradient *gradient; GtkWidget *dialog; context = gimp_container_view_get_context (editor->view); gradient = gimp_context_get_gradient (context); if (! gradient) return; #define SAVE_AS_POV_DIALOG_KEY "gimp-save-as-pov-ray-dialog" dialog = dialogs_get_dialog (G_OBJECT (gradient), SAVE_AS_POV_DIALOG_KEY); if (! dialog) { gchar *title = g_strdup_printf (_("Save '%s' as POV-Ray"), gimp_object_get_name (gradient)); dialog = gtk_file_chooser_dialog_new (title, NULL, GTK_FILE_CHOOSER_ACTION_SAVE, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Save"), GTK_RESPONSE_OK, NULL); g_free (title); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); g_object_set_data (G_OBJECT (dialog), "gimp", context->gimp); gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (GTK_WIDGET (editor))); gtk_window_set_role (GTK_WINDOW (dialog), "gimp-gradient-save-pov"); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); g_signal_connect (dialog, "response", G_CALLBACK (gradients_save_as_pov_ray_response), gradient); g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect_object (dialog, "destroy", G_CALLBACK (g_object_unref), g_object_ref (gradient), G_CONNECT_SWAPPED); gimp_help_connect (dialog, gimp_standard_help_func, GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL); dialogs_attach_dialog (G_OBJECT (gradient), SAVE_AS_POV_DIALOG_KEY, dialog); } gtk_window_present (GTK_WINDOW (dialog)); }
void mate_panel_applet_position_menu (GtkMenu *menu, int *x, int *y, gboolean *push_in, GtkWidget *applet) { GtkAllocation allocation; GtkRequisition requisition; GdkScreen *screen; GtkWidget *parent; int menu_x = 0; int menu_y = 0; int pointer_x; int pointer_y; parent = gtk_widget_get_parent (applet); g_return_if_fail (PANEL_IS_WIDGET (parent)); screen = gtk_widget_get_screen (applet); gtk_widget_size_request (GTK_WIDGET (menu), &requisition); gdk_window_get_origin (gtk_widget_get_window (applet), &menu_x, &menu_y); gtk_widget_get_pointer (applet, &pointer_x, &pointer_y); gtk_widget_get_allocation (applet, &allocation); if (!gtk_widget_get_has_window (applet)) { menu_x += allocation.x; menu_y += allocation.y; } if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) { if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) { if (pointer_x < allocation.width && requisition.width < pointer_x) menu_x += MIN (pointer_x, allocation.width - requisition.width); } else { menu_x += allocation.width - requisition.width; if (pointer_x > 0 && pointer_x < allocation.width && pointer_x < allocation.width - requisition.width) { menu_x -= MIN (allocation.width - pointer_x, allocation.width - requisition.width); } } menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width); if (menu_y > gdk_screen_get_height (screen) / 2) menu_y -= requisition.height; else menu_y += allocation.height; } else { if (pointer_y < allocation.height && requisition.height < pointer_y) menu_y += MIN (pointer_y, allocation.height - requisition.height); menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height); if (menu_x > gdk_screen_get_width (screen) / 2) menu_x -= requisition.width; else menu_x += allocation.width; } *x = menu_x; *y = menu_y; *push_in = TRUE; }
static GdkPixbuf * render_icon (GtkStyle *style, const GtkIconSource *source, GtkTextDirection direction, GtkStateType state, GtkIconSize size, GtkWidget *widget, const gchar *detail) { int width = 1; int height = 1; GdkPixbuf *scaled; GdkPixbuf *stated; GdkPixbuf *base_pixbuf; GdkScreen *screen; GtkSettings *settings; /* Oddly, style can be NULL in this function, because * GtkIconSet can be used without a style and if so * it uses this function. */ base_pixbuf = gtk_icon_source_get_pixbuf (source); g_return_val_if_fail (base_pixbuf != NULL, NULL); if (widget && gtk_widget_has_screen (widget)) { screen = gtk_widget_get_screen (widget); settings = gtk_settings_get_for_screen (screen); } else if (style->colormap) { screen = gdk_colormap_get_screen (style->colormap); settings = gtk_settings_get_for_screen (screen); } else { settings = gtk_settings_get_default (); GTK_NOTE (MULTIHEAD, g_warning ("Using the default screen for gtk_default_render_icon()")); } if (size != (GtkIconSize) -1 && !gtk_icon_size_lookup_for_settings (settings, size, &width, &height)) { g_warning (G_STRLOC ": invalid icon size '%d'", size); return NULL; } /* If the size was wildcarded, and we're allowed to scale, then scale; otherwise, * leave it alone. */ if (size != (GtkIconSize)-1 && gtk_icon_source_get_size_wildcarded (source)) scaled = scale_or_ref (base_pixbuf, width, height); else scaled = g_object_ref (base_pixbuf); /* If the state was wildcarded, then generate a state. */ if (gtk_icon_source_get_state_wildcarded (source)) { if (state == GTK_STATE_INSENSITIVE) { stated = set_transparency (scaled, 0.3); gdk_pixbuf_saturate_and_pixelate (stated, stated, 0.1, FALSE); g_object_unref (scaled); } else if (state == GTK_STATE_PRELIGHT) { stated = gdk_pixbuf_copy (scaled); gdk_pixbuf_saturate_and_pixelate (scaled, stated, 1.2, FALSE); g_object_unref (scaled); } else { stated = scaled; } } else stated = scaled; return stated; }
GtkWidget * do_infobar (GtkWidget *do_widget) { GtkWidget *frame; GtkWidget *bar; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *label; if (!window) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Info Bars"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); gtk_container_set_border_width (GTK_CONTAINER (window), 8); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); bar = gtk_info_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO); label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_INFO"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); bar = gtk_info_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_WARNING); label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_WARNING"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); bar = gtk_info_bar_new_with_buttons (GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_signal_connect (bar, "response", G_CALLBACK (on_bar_response), window); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_QUESTION); label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_QUESTION"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); bar = gtk_info_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_ERROR); label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_ERROR"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); bar = gtk_info_bar_new (); gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0); gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_OTHER); label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_OTHER"); gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE, 0); frame = gtk_frame_new ("Info bars"); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 8); vbox2 = gtk_vbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); gtk_container_add (GTK_CONTAINER (frame), vbox2); /* Standard message dialog */ label = gtk_label_new ("An example of different info bars"); gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0); } if (!gtk_widget_get_visible (window)) { gtk_widget_show_all (window); } else { gtk_widget_destroy (window); window = NULL; } return window; }
GtkWidget * do_colorsel (GtkWidget *do_widget) { GtkWidget *vbox; GtkWidget *button; GtkWidget *alignment; if (!window) { color.red = 0; color.blue = 1; color.green = 0; color.alpha = 1; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Color Selection"); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); gtk_container_set_border_width (GTK_CONTAINER (window), 8); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); gtk_container_add (GTK_CONTAINER (window), vbox); /* * Create the color swatch area */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); da = gtk_drawing_area_new (); g_signal_connect (da, "draw", G_CALLBACK (draw_callback), NULL); /* set a minimum size */ gtk_widget_set_size_request (da, 200, 200); /* set the color */ gtk_widget_override_background_color (da, 0, &color); gtk_container_add (GTK_CONTAINER (frame), da); alignment = gtk_alignment_new (1.0, 0.5, 0.0, 0.0); button = gtk_button_new_with_mnemonic ("_Change the above color"); gtk_container_add (GTK_CONTAINER (alignment), button); gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0); g_signal_connect (button, "clicked", G_CALLBACK (change_color_callback), NULL); } if (!gtk_widget_get_visible (window)) { gtk_widget_show_all (window); } else { gtk_widget_destroy (window); window = NULL; } return window; }
/* Lock Screen */ static void panel_action_lock_screen(GtkWidget* widget) { panel_lock_screen(gtk_widget_get_screen(widget)); }
static void gimp_controller_list_edit_clicked (GtkWidget *button, GimpControllerList *list) { GtkWidget *dialog; GtkWidget *editor; dialog = g_object_get_data (G_OBJECT (list->dest_info), "gimp-controller-editor-dialog"); if (dialog) { gtk_window_present (GTK_WINDOW (dialog)); return; } dialog = gimp_dialog_new (_("Configure Input Controller"), "gimp-controller-editor-dialog", gtk_widget_get_toplevel (GTK_WIDGET (list)), GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, GIMP_HELP_PREFS_INPUT_CONTROLLERS, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gimp_dialog_factory_add_foreign (gimp_dialog_factory_get_singleton (), "gimp-controller-editor-dialog", dialog, gtk_widget_get_screen (button), gimp_widget_get_monitor (button)); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); editor = gimp_controller_editor_new (list->dest_info, gimp_get_user_context (list->gimp)); gtk_container_set_border_width (GTK_CONTAINER (editor), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), editor, TRUE, TRUE, 0); gtk_widget_show (editor); g_object_set_data (G_OBJECT (list->dest_info), "gimp-controller-editor-dialog", dialog); g_signal_connect_object (dialog, "destroy", G_CALLBACK (gimp_controller_list_edit_destroy), G_OBJECT (list->dest_info), 0); g_signal_connect_object (list, "destroy", G_CALLBACK (gtk_widget_destroy), G_OBJECT (dialog), G_CONNECT_SWAPPED); g_signal_connect_object (list, "unmap", G_CALLBACK (gtk_widget_destroy), G_OBJECT (dialog), G_CONNECT_SWAPPED); gtk_widget_show (dialog); }
/* Run Application */ static void panel_action_run_program (GtkWidget *widget) { panel_run_dialog_present (gtk_widget_get_screen (widget), gtk_get_current_event_time ()); }
// Get the display ICC profile of the monitor associated with the widget. // For X display, uses the ICC profile specifications version 0.2 from // http://burtonini.com/blog/computers/xicc // Based on code from Gimp's modules/cdisplay_lcms.c void dt_ctl_set_display_profile() { if(!dt_control_running()) return; // make sure that no one gets a broken profile // FIXME: benchmark if the try is really needed when moving/resizing the window. Maybe we can just lock it // and block if(pthread_rwlock_trywrlock(&darktable.control->xprofile_lock)) return; // we are already updating the profile. Or someone is reading right now. Too bad we can't // distinguish that. Whatever ... GtkWidget *widget = dt_ui_center(darktable.gui->ui); guint8 *buffer = NULL; gint buffer_size = 0; gchar *profile_source = NULL; #if defined GDK_WINDOWING_X11 // we will use the xatom no matter what configured when compiled without colord gboolean use_xatom = TRUE; #if defined USE_COLORDGTK gboolean use_colord = TRUE; gchar *display_profile_source = dt_conf_get_string("ui_last/display_profile_source"); if(display_profile_source) { if(!strcmp(display_profile_source, "xatom")) use_colord = FALSE; else if(!strcmp(display_profile_source, "colord")) use_xatom = FALSE; g_free(display_profile_source); } #endif /* let's have a look at the xatom, just in case ... */ if(use_xatom) { GdkScreen *screen = gtk_widget_get_screen(widget); if(screen == NULL) screen = gdk_screen_get_default(); int monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget)); char *atom_name; if(monitor > 0) atom_name = g_strdup_printf("_ICC_PROFILE_%d", monitor); else atom_name = g_strdup("_ICC_PROFILE"); profile_source = g_strdup_printf("xatom %s", atom_name); GdkAtom type = GDK_NONE; gint format = 0; gdk_property_get(gdk_screen_get_root_window(screen), gdk_atom_intern(atom_name, FALSE), GDK_NONE, 0, 64 * 1024 * 1024, FALSE, &type, &format, &buffer_size, &buffer); g_free(atom_name); } #ifdef USE_COLORDGTK /* also try to get the profile from colord. this will set the value asynchronously! */ if(use_colord) { CdWindow *window = cd_window_new(); GtkWidget *center_widget = dt_ui_center(darktable.gui->ui); cd_window_get_profile(window, center_widget, NULL, dt_ctl_get_display_profile_colord_callback, NULL); } #endif #elif defined GDK_WINDOWING_QUARTZ GdkScreen *screen = gtk_widget_get_screen(widget); if(screen == NULL) screen = gdk_screen_get_default(); int monitor = gdk_screen_get_monitor_at_window(screen, gtk_widget_get_window(widget)); CGDirectDisplayID ids[monitor + 1]; uint32_t total_ids; CMProfileRef prof = NULL; if(CGGetOnlineDisplayList(monitor + 1, &ids[0], &total_ids) == kCGErrorSuccess && total_ids == monitor + 1) CMGetProfileByAVID(ids[monitor], &prof); if(prof != NULL) { CFDataRef data; data = CMProfileCopyICCData(NULL, prof); CMCloseProfile(prof); UInt8 *tmp_buffer = (UInt8 *)g_malloc(CFDataGetLength(data)); CFDataGetBytes(data, CFRangeMake(0, CFDataGetLength(data)), tmp_buffer); buffer = (guint8 *)tmp_buffer; buffer_size = CFDataGetLength(data); CFRelease(data); } profile_source = g_strdup("osx color profile api"); #elif defined G_OS_WIN32 (void)widget; HDC hdc = GetDC(NULL); if(hdc != NULL) { DWORD len = 0; GetICMProfile(hdc, &len, NULL); gchar *path = g_new(gchar, len); if(GetICMProfile(hdc, &len, path)) { gsize size; g_file_get_contents(path, (gchar **)&buffer, &size, NULL); buffer_size = size; } g_free(path); ReleaseDC(NULL, hdc); } profile_source = g_strdup("windows color profile api"); #endif int profile_changed = buffer_size > 0 && (darktable.control->xprofile_size != buffer_size || memcmp(darktable.control->xprofile_data, buffer, buffer_size) != 0); if(profile_changed) { cmsHPROFILE profile = NULL; char name[512] = { 0 }; // thanks to ufraw for this! g_free(darktable.control->xprofile_data); darktable.control->xprofile_data = buffer; darktable.control->xprofile_size = buffer_size; profile = cmsOpenProfileFromMem(buffer, buffer_size); if(profile) { dt_colorspaces_get_profile_name(profile, "en", "US", name, sizeof(name)); cmsCloseProfile(profile); } dt_print(DT_DEBUG_CONTROL, "[color profile] we got a new screen profile `%s' from the %s (size: %d)\n", *name ? name : "(unknown)", profile_source, buffer_size); } pthread_rwlock_unlock(&darktable.control->xprofile_lock); if(profile_changed) dt_control_signal_raise(darktable.signals, DT_SIGNAL_CONTROL_PROFILE_CHANGED); g_free(profile_source); }
GtkWidget * do_hypertext (GtkWidget *do_widget) { static GtkWidget *window = NULL; if (!window) { GtkWidget *view; GtkWidget *sw; GtkTextBuffer *buffer; hand_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_HAND2); regular_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_XTERM); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); gtk_window_set_default_size (GTK_WINDOW (window), 450, 450); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); gtk_window_set_title (GTK_WINDOW (window), "Hypertext"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); view = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); g_signal_connect (view, "key-press-event", G_CALLBACK (key_press_event), NULL); g_signal_connect (view, "event-after", G_CALLBACK (event_after), NULL); g_signal_connect (view, "motion-notify-event", G_CALLBACK (motion_notify_event), NULL); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (window), sw); gtk_container_add (GTK_CONTAINER (sw), view); show_page (buffer, 1); gtk_widget_show_all (sw); } if (!gtk_widget_get_visible (window)) { gtk_widget_show (window); } else { gtk_widget_destroy (window); window = NULL; } return window; }