static void remove_notebook (GeditMultiNotebook *mnb, GtkWidget *notebook) { GtkWidget *parent; GtkWidget *grandpa; GList *children; GtkWidget *new_notebook; GList *current; if (mnb->priv->notebooks->next == NULL) { g_warning ("You are trying to remove the main notebook"); return; } current = g_list_find (mnb->priv->notebooks, notebook); if (current->next != NULL) { new_notebook = GTK_WIDGET (current->next->data); } else { new_notebook = GTK_WIDGET (mnb->priv->notebooks->data); } parent = gtk_widget_get_parent (notebook); /* Now we destroy the widget, we get the children of parent and we destroy parent too as the parent is an useless paned. Finally we add the child into the grand parent */ g_object_ref (notebook); mnb->priv->removing_notebook = TRUE; gtk_widget_destroy (notebook); mnb->priv->notebooks = g_list_remove (mnb->priv->notebooks, notebook); mnb->priv->removing_notebook = FALSE; children = gtk_container_get_children (GTK_CONTAINER (parent)); if (children->next != NULL) { g_warning ("The parent is not a paned"); return; } grandpa = gtk_widget_get_parent (parent); g_object_ref (children->data); gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (children->data)); gtk_widget_destroy (parent); gtk_container_add (GTK_CONTAINER (grandpa), GTK_WIDGET (children->data)); g_object_unref (children->data); g_list_free (children); disconnect_notebook_signals (mnb, notebook); g_signal_emit (G_OBJECT (mnb), signals[NOTEBOOK_REMOVED], 0, notebook); g_object_unref (notebook); /* Let's make the active notebook grab the focus */ gtk_widget_grab_focus (new_notebook); }
static void monitor_create_options(Control *control, GtkContainer *container, GtkWidget *done) { t_global_monitor *global; GtkBox *vbox, *global_vbox, *net_hbox; GtkWidget *device_label, *unit_label[SUM], *max_label[SUM]; GtkWidget *sep1, *sep2; GtkBox *update_hbox; GtkWidget *update_label, *update_unit_label; GtkWidget *color_label[SUM]; GtkWidget *align; GtkBox *color_hbox[SUM]; GtkSizeGroup *sg; gint i; gchar buffer[BUFSIZ]; gchar *color_text[] = { N_("Bar color (incoming):"), N_("Bar color (outgoing):") }; gchar *maximum_text_label[] = { N_("Maximum (incoming):"), N_("Maximum (outgoing):") }; sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); global = (t_global_monitor *)control->data; global->opt_dialog = gtk_widget_get_toplevel(done); global_vbox = GTK_BOX(gtk_vbox_new(FALSE, 5)); gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(global_vbox)); gtk_widget_show_all(GTK_WIDGET(global_vbox)); vbox = GTK_BOX(gtk_vbox_new(FALSE, 5)); gtk_widget_show(GTK_WIDGET(vbox)); global->monitor->opt_vbox = GTK_BOX(gtk_vbox_new(FALSE, 5)); gtk_widget_show(GTK_WIDGET(global->monitor->opt_vbox)); /* Displayed text */ global->monitor->opt_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_widget_show(GTK_WIDGET(global->monitor->opt_hbox)); global->monitor->opt_use_label = gtk_check_button_new_with_mnemonic(_("Text to display:")); gtk_widget_show(global->monitor->opt_use_label); gtk_box_pack_start(GTK_BOX(global->monitor->opt_hbox), GTK_WIDGET(global->monitor->opt_use_label), FALSE, FALSE, 0); gtk_size_group_add_widget(sg, global->monitor->opt_use_label); global->monitor->opt_entry = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(global->monitor->opt_entry), MAX_LENGTH); gtk_entry_set_text(GTK_ENTRY(global->monitor->opt_entry), global->monitor->options.label_text); gtk_widget_show(global->monitor->opt_entry); gtk_box_pack_start(GTK_BOX(global->monitor->opt_hbox), GTK_WIDGET(global->monitor->opt_entry), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(global->monitor->opt_hbox), FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->opt_use_label), global->monitor->options.use_label); gtk_widget_set_sensitive(GTK_WIDGET(global->monitor->opt_entry), global->monitor->options.use_label); /* Network device */ net_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(net_hbox), FALSE, FALSE, 0); device_label = gtk_label_new(_("Network device:")); gtk_misc_set_alignment(GTK_MISC(device_label), 0, 0.5); gtk_widget_show(GTK_WIDGET(device_label)); gtk_box_pack_start(GTK_BOX(net_hbox), GTK_WIDGET(device_label), FALSE, FALSE, 0); global->monitor->net_entry = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(global->monitor->net_entry), MAX_LENGTH); gtk_entry_set_text(GTK_ENTRY(global->monitor->net_entry), global->monitor->options.network_device); gtk_widget_show(global->monitor->opt_entry); gtk_box_pack_start(GTK_BOX(net_hbox), GTK_WIDGET(global->monitor->net_entry), FALSE, FALSE, 0); gtk_size_group_add_widget(sg, device_label); gtk_widget_show_all(GTK_WIDGET(net_hbox)); /* Update timevalue */ update_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(update_hbox), FALSE, FALSE, 0); update_label = gtk_label_new(_("Update interval:")); gtk_misc_set_alignment(GTK_MISC(update_label), 0, 0.5); gtk_box_pack_start(GTK_BOX(update_hbox), GTK_WIDGET(update_label), FALSE, FALSE, 0); global->monitor->update_spinner = gtk_spin_button_new_with_range (0.1, 10.0, 0.05); gtk_spin_button_set_digits( GTK_SPIN_BUTTON(global->monitor->update_spinner), 2 ); gtk_spin_button_set_value( GTK_SPIN_BUTTON(global->monitor->update_spinner), global->monitor->options.update_interval / 1000.0 ); gtk_box_pack_start(GTK_BOX(update_hbox), GTK_WIDGET(global->monitor->update_spinner), FALSE, FALSE, 0); update_unit_label = gtk_label_new(_("ms")); gtk_box_pack_start(GTK_BOX(update_hbox), GTK_WIDGET(update_unit_label), FALSE, FALSE, 0); gtk_widget_show_all(GTK_WIDGET(update_hbox)); gtk_size_group_add_widget(sg, update_label); sep1 = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(sep1), FALSE, FALSE, 0); gtk_widget_show(sep1); global->monitor->max_use_label = gtk_check_button_new_with_mnemonic(_("Automatic maximum")); gtk_widget_show(global->monitor->max_use_label); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(global->monitor->max_use_label), FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->max_use_label), global->monitor->options.auto_max); /* Input maximum */ for( i = 0; i < SUM; i++) { global->monitor->max_hbox[i] = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(global->monitor->max_hbox[i]), FALSE, FALSE, 0); max_label[i] = gtk_label_new(_(maximum_text_label[i])); gtk_misc_set_alignment(GTK_MISC(max_label[i]), 0, 0.5); gtk_widget_show(GTK_WIDGET(max_label[i])); gtk_box_pack_start(GTK_BOX(global->monitor->max_hbox[i]), GTK_WIDGET(max_label[i]), FALSE, FALSE, 0); global->monitor->max_entry[i] = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(global->monitor->max_entry[i]), MAX_LENGTH); g_snprintf( buffer, BUFSIZ, "%.2f", global->monitor->options.max[i] / 1024.0 ); gtk_entry_set_text(GTK_ENTRY(global->monitor->max_entry[i]), buffer); gtk_entry_set_width_chars(GTK_ENTRY(global->monitor->max_entry[i]), 7); gtk_widget_show(global->monitor->max_entry[i]); gtk_box_pack_start(GTK_BOX(global->monitor->max_hbox[i]), GTK_WIDGET(global->monitor->max_entry[i]), FALSE, FALSE, 0); unit_label[i] = gtk_label_new(_("kByte/s")); gtk_box_pack_start(GTK_BOX(global->monitor->max_hbox[i]), GTK_WIDGET(unit_label[i]), FALSE, FALSE, 0); gtk_size_group_add_widget(sg, max_label[i]); gtk_widget_show_all(GTK_WIDGET(global->monitor->max_hbox[i])); gtk_widget_set_sensitive(GTK_WIDGET(global->monitor->max_hbox[i]), !(global->monitor->options.auto_max) ); g_signal_connect(GTK_WIDGET(global->monitor->max_entry[i]), "activate", G_CALLBACK(max_label_changed), global); } sep2 = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(sep2), FALSE, FALSE, 0); gtk_widget_show(sep2); /* Color 1 */ for (i = 0; i < SUM; i++) { color_hbox[i] = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_widget_show(GTK_WIDGET(color_hbox[i])); gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox), GTK_WIDGET(color_hbox[i]), FALSE, FALSE, 0); color_label[i] = gtk_label_new(_(color_text[i])); gtk_misc_set_alignment(GTK_MISC(color_label[i]), 0, 0.5); gtk_widget_show(GTK_WIDGET(color_label[i])); gtk_box_pack_start(GTK_BOX(color_hbox[i]), GTK_WIDGET(color_label[i]), FALSE, FALSE, 0); global->monitor->opt_button[i] = gtk_button_new(); global->monitor->opt_da[i] = gtk_drawing_area_new(); gtk_widget_modify_bg(global->monitor->opt_da[i], GTK_STATE_NORMAL, &global->monitor->options.color[i]); gtk_widget_set_size_request(global->monitor->opt_da[i], 64, 12); gtk_container_add(GTK_CONTAINER(global->monitor->opt_button[i]), global->monitor->opt_da[i]); gtk_widget_show(GTK_WIDGET(global->monitor->opt_button[i])); gtk_widget_show(GTK_WIDGET(global->monitor->opt_da[i])); gtk_box_pack_start(GTK_BOX(color_hbox[i]), GTK_WIDGET(global->monitor->opt_button[i]), FALSE, FALSE, 0); gtk_size_group_add_widget(sg, color_label[i]); } gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(global->monitor->opt_vbox), FALSE, FALSE, 0); align = gtk_alignment_new(0, 0, 0, 0); gtk_widget_set_size_request(align, 5, 5); gtk_widget_show(GTK_WIDGET(align)); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(align), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX(global_vbox), GTK_WIDGET(vbox), FALSE, FALSE, 0); g_signal_connect(GTK_WIDGET(global->monitor->max_use_label), "toggled", G_CALLBACK(max_label_toggled), global); g_signal_connect(GTK_WIDGET(global->monitor->opt_da[0]), "expose_event", G_CALLBACK(expose_event_cb), NULL); g_signal_connect(GTK_WIDGET(global->monitor->opt_da[1]), "expose_event", G_CALLBACK(expose_event_cb), NULL); g_signal_connect(GTK_WIDGET(global->monitor->opt_button[IN]), "clicked", G_CALLBACK(change_color_in), global); g_signal_connect(GTK_WIDGET(global->monitor->opt_button[OUT]), "clicked", G_CALLBACK(change_color_out), global); g_signal_connect(GTK_WIDGET(global->monitor->opt_use_label), "toggled", G_CALLBACK(label_toggled), global); g_signal_connect(GTK_WIDGET(global->monitor->opt_entry), "activate", G_CALLBACK(label_changed), global); g_signal_connect(GTK_WIDGET(global->monitor->net_entry), "activate", G_CALLBACK(network_changed), global); g_signal_connect(GTK_WIDGET(done), "clicked", G_CALLBACK(monitor_apply_options_cb), global); }
static gboolean gail_focus_watcher (GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, gpointer data) { GObject *object; GtkWidget *widget; GdkEvent *event; object = g_value_get_object (param_values + 0); g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE); event = g_value_get_boxed (param_values + 1); widget = GTK_WIDGET (object); if (event->type == GDK_FOCUS_CHANGE) { if (event->focus_change.in) { if (GTK_IS_WINDOW (widget)) { GtkWindow *window; window = GTK_WINDOW (widget); if (window->focus_widget) { /* * If we already have a potential focus widget set this * windows's focus widget to focus_before_menu so that * it will be reported when menu item is unset. */ if (next_focus_widget) { if (GTK_IS_MENU_ITEM (next_focus_widget) && !focus_before_menu) { void *vp_focus_before_menu = &focus_before_menu; focus_before_menu = window->focus_widget; g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu); } return TRUE; } widget = window->focus_widget; } else if (window->type == GTK_WINDOW_POPUP) { if (GTK_IS_BIN (widget)) { GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); if (GTK_IS_WIDGET (child) && GTK_WIDGET_HAS_GRAB (child)) { if (GTK_IS_MENU_SHELL (child)) { if (GTK_MENU_SHELL (child)->active_menu_item) { /* * We have a menu which has a menu item selected * so we do not report focus on the menu. */ return TRUE; } } widget = child; } } else /* popup window has no children; this edge case occurs in some custom code (OOo for instance) */ { return TRUE; } } else /* Widget is a non-popup toplevel with no focus children; don't emit for this case either, as it's useless */ { return TRUE; } } } else { if (next_focus_widget) { GtkWidget *toplevel; toplevel = gtk_widget_get_toplevel (next_focus_widget); if (toplevel == widget) next_focus_widget = NULL; } /* focus out */ widget = NULL; } } else { if (event->type == GDK_MOTION_NOTIFY && GTK_WIDGET_HAS_FOCUS (widget)) { if (widget == focus_widget) { return TRUE; } } else { return TRUE; } } /* * If the focus widget is a GtkSocket without a plug * then ignore the focus notification as the embedded * plug will report a focus notification. */ if (GTK_IS_SOCKET (widget) && GTK_SOCKET (widget)->plug_widget == NULL) return TRUE; /* * The widget may not yet be visible on the screen so we wait until it is. */ gail_focus_notify_when_idle (widget); return TRUE; }
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool) { GimpTool *tool = GIMP_TOOL (picker_tool); GimpDisplayShell *shell; GtkWidget *hbox; GtkWidget *frame; GimpRGB color; g_return_if_fail (tool->display != NULL); g_return_if_fail (tool->drawable != NULL); shell = gimp_display_get_shell (tool->display); picker_tool->gui = gimp_tool_gui_new (tool->tool_info, _("Color Picker Information"), gtk_widget_get_screen (GTK_WIDGET (shell)), gimp_widget_get_monitor (GTK_WIDGET (shell)), TRUE, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); gimp_tool_gui_set_auto_overlay (picker_tool->gui, TRUE); gimp_tool_gui_set_focus_on_map (picker_tool->gui, FALSE); gimp_tool_gui_set_viewable (picker_tool->gui, GIMP_VIEWABLE (tool->drawable)); g_signal_connect (picker_tool->gui, "response", G_CALLBACK (gimp_color_picker_tool_info_response), picker_tool); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (picker_tool->gui)), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); picker_tool->color_frame1 = gimp_color_frame_new (); gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame1), GIMP_COLOR_FRAME_MODE_PIXEL); gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame1, FALSE, FALSE, 0); gtk_widget_show (picker_tool->color_frame1); picker_tool->color_frame2 = gimp_color_frame_new (); gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame2), GIMP_COLOR_FRAME_MODE_RGB); gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame2, FALSE, FALSE, 0); gtk_widget_show (picker_tool->color_frame2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0); picker_tool->color_area = gimp_color_area_new (&color, gimp_drawable_has_alpha (tool->drawable) ? GIMP_COLOR_AREA_LARGE_CHECKS : GIMP_COLOR_AREA_FLAT, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK); gtk_widget_set_size_request (picker_tool->color_area, 48, -1); gtk_drag_dest_unset (picker_tool->color_area); gtk_container_add (GTK_CONTAINER (frame), picker_tool->color_area); gtk_widget_show (picker_tool->color_area); }
static t_global_monitor * monitor_new(void) { t_global_monitor *global; GtkRcStyle *rc; gint i; global = g_new(t_global_monitor, 1); global->timeout_id = 0; global->ebox = gtk_event_box_new(); gtk_widget_show(global->ebox); global->box = gtk_hbox_new(FALSE, 0); gtk_widget_show(global->box); if (!tooltips) { tooltips = gtk_tooltips_new(); } global->monitor = g_new(t_monitor, 1); global->monitor->options.label_text = g_strdup(DEFAULT_TEXT); global->monitor->options.network_device = g_strdup(DEFAULT_DEVICE); global->monitor->options.old_network_device = g_strdup(""); global->monitor->options.use_label = TRUE; global->monitor->options.auto_max = TRUE; global->monitor->options.update_interval = UPDATE_TIMEOUT; for (i = 0; i < SUM; i++) { gdk_color_parse(DEFAULT_COLOR[i], &global->monitor->options.color[i]); global->monitor->history[i][0] = 0; global->monitor->history[i][1] = 0; global->monitor->history[i][2] = 0; global->monitor->history[i][3] = 0; global->monitor->net_max[i] = INIT_MAX; global->monitor->options.max[i] = INIT_MAX; } global->monitor->ebox = gtk_event_box_new(); gtk_widget_show(global->monitor->ebox); global->monitor->box = GTK_WIDGET(gtk_hbox_new(FALSE, 0)); gtk_container_set_border_width(GTK_CONTAINER(global->monitor->box), border_width); gtk_widget_show(GTK_WIDGET(global->monitor->box)); gtk_container_add(GTK_CONTAINER(global->monitor->ebox), GTK_WIDGET(global->monitor->box)); global->monitor->label = gtk_label_new(global->monitor->options.label_text); gtk_widget_show(global->monitor->label); gtk_box_pack_start(GTK_BOX(global->monitor->box), GTK_WIDGET(global->monitor->label), FALSE, FALSE, 0); for (i = 0; i < SUM; i++) { global->monitor->status[i] = GTK_WIDGET(gtk_progress_bar_new()); gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]), GTK_PROGRESS_BOTTOM_TO_TOP); rc = gtk_widget_get_modifier_style(GTK_WIDGET(global->monitor->status[i])); if (!rc) { rc = gtk_rc_style_new(); } else { rc->color_flags[GTK_STATE_PRELIGHT] |= GTK_RC_BG; rc->bg[GTK_STATE_PRELIGHT] = global->monitor->options.color[i]; } gtk_widget_modify_style(GTK_WIDGET(global->monitor->status[i]), rc); gtk_widget_show(GTK_WIDGET(global->monitor->status[i])); gtk_box_pack_start(GTK_BOX(global->monitor->box), GTK_WIDGET(global->monitor->status[i]), FALSE, FALSE, 0); } gtk_box_pack_start(GTK_BOX(global->box), GTK_WIDGET(global->monitor->ebox), FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(global->ebox), GTK_WIDGET(global->box)); return global; }
static void gimp_color_tool_real_picked (GimpColorTool *color_tool, GimpColorPickState pick_state, gdouble x, gdouble y, const Babl *sample_format, gpointer pixel, const GimpRGB *color) { GimpTool *tool = GIMP_TOOL (color_tool); GimpContext *context; /* use this tool's own options here (NOT color_tool->options) */ context = GIMP_CONTEXT (gimp_tool_get_options (tool)); if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND || color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND) { GtkWidget *widget; if (babl_format_is_palette (sample_format)) { widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-indexed-palette"); if (widget) { GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget)); guchar *index = pixel; gimp_colormap_editor_set_index (GIMP_COLORMAP_EDITOR (editor), *index, NULL); } } widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (), "gimp-palette-editor"); if (widget) { GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget)); gint index; index = gimp_palette_editor_get_index (GIMP_PALETTE_EDITOR (editor), color); if (index != -1) gimp_palette_editor_set_index (GIMP_PALETTE_EDITOR (editor), index, NULL); } } switch (color_tool->pick_mode) { case GIMP_COLOR_PICK_MODE_NONE: break; case GIMP_COLOR_PICK_MODE_FOREGROUND: gimp_context_set_foreground (context, color); break; case GIMP_COLOR_PICK_MODE_BACKGROUND: gimp_context_set_background (context, color); break; case GIMP_COLOR_PICK_MODE_PALETTE: { GimpDisplayShell *shell = gimp_display_get_shell (tool->display); GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (shell)); gint monitor = gimp_widget_get_monitor (GTK_WIDGET (shell)); GtkWidget *dockable; dockable = gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)), tool->display->gimp, gimp_dialog_factory_get_singleton (), screen, monitor, "gimp-palette-editor"); if (dockable) { GtkWidget *palette_editor; GimpData *data; /* don't blink like mad when updating */ if (pick_state != GIMP_COLOR_PICK_STATE_START) gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable)); palette_editor = gtk_bin_get_child (GTK_BIN (dockable)); data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor)); if (! data) { data = GIMP_DATA (gimp_context_get_palette (context)); gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor), data); } gimp_palette_editor_pick_color (GIMP_PALETTE_EDITOR (palette_editor), color, pick_state); } } break; } }
static void impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook) { RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source); RhythmDBQueryModel *model; GtkBuilder *builder; GtkWidget *widget; GString *str; char *device_name; char *builder_file; char *vendor_name; char *model_name; char *serial_id; GObject *plugin; char *text; GList *output_formats; GList *t; g_object_get (source, "plugin", &plugin, NULL); builder_file = rb_find_plugin_data_file (plugin, "generic-player-info.ui"); g_object_unref (plugin); if (builder_file == NULL) { g_warning ("Couldn't find generic-player-info.ui"); return; } builder = rb_builder_load (builder_file, NULL); g_free (builder_file); if (builder == NULL) { rb_debug ("Couldn't load generic-player-info.ui"); return; } /* 'basic' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-basic-info")); gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0); widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry-device-name")); g_object_get (source, "name", &device_name, NULL); gtk_entry_set_text (GTK_ENTRY (widget), device_name); g_free (device_name); /* don't think we can support this.. g_signal_connect (widget, "focus-out-event", (GCallback)rb_mtp_source_name_changed_cb, source); */ g_object_get (source, "base-query-model", &model, NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-tracks")); text = g_strdup_printf ("%d", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL)); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); g_object_unref (model); widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-playlists")); text = g_strdup_printf ("%d", g_list_length (priv->playlists)); gtk_label_set_text (GTK_LABEL (widget), text); g_free (text); /* 'advanced' tab stuff */ widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-advanced-tab")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, gtk_label_new (_("Advanced"))); g_object_get (priv->device_info, "model", &model_name, "vendor", &vendor_name, "serial", &serial_id, NULL); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-model-value")); gtk_label_set_text (GTK_LABEL (widget), model_name); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-manufacturer-value")); gtk_label_set_text (GTK_LABEL (widget), vendor_name); widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-serial-number-value")); gtk_label_set_text (GTK_LABEL (widget), serial_id); g_free (model_name); g_free (vendor_name); g_free (serial_id); str = g_string_new (""); output_formats = rb_transfer_target_get_format_descriptions (RB_TRANSFER_TARGET (source)); for (t = output_formats; t != NULL; t = t->next) { if (t != output_formats) { g_string_append (str, "\n"); } g_string_append (str, t->data); } rb_list_deep_free (output_formats); widget = GTK_WIDGET (gtk_builder_get_object (builder, "audio-format-list")); gtk_label_set_text (GTK_LABEL (widget), str->str); g_string_free (str, TRUE); g_object_unref (builder); }
Plugin::Plugin(XfcePanelPlugin *xfce_plugin_) : xfce_plugin(xfce_plugin_), // Setting defaults icon_path("/usr/share/pixmaps/xfce4-hardware-monitor-plugin.png"), viewer_type("curve"), viewer_font(""), viewer_size(96), // Arbitrary default, see later in this function for notes background_color(0x000000FF), // Black as the night - note that the // transparency bits need to be set to max to // ensure the colour is visible use_background_color(false), next_color(0), viewer_text_overlay_enabled(false), viewer_text_overlay_format_string("%a %m"), viewer_text_overlay_separator(" "), viewer_text_overlay_font(""), viewer_text_overlay_use_font(false), viewer_text_overlay_color(0x000000FF), viewer_text_overlay_position(CanvasView::top_left), viewer_monitor_type_sync_enabled(true) { // Search for settings file XfceRc* settings_ro = NULL; gchar* file = xfce_panel_plugin_lookup_rc_file(xfce_plugin); if (file) { // One exists - loading settings settings_ro = xfce_rc_simple_open(file, true); g_free(file); // Ensuring default group is in focus xfce_rc_set_group(settings_ro, NULL); icon_path = xfce_rc_read_entry(settings_ro, "icon-path", icon_path.c_str()); viewer_type = xfce_rc_read_entry(settings_ro, "viewer_type", viewer_type.c_str()); viewer_size = xfce_rc_read_int_entry(settings_ro, "viewer_size", viewer_size); viewer_font = xfce_rc_read_entry(settings_ro, "viewer_font", viewer_font.c_str()); background_color = xfce_rc_read_int_entry(settings_ro, "background_color", background_color); use_background_color = xfce_rc_read_bool_entry(settings_ro, "use_background_color", use_background_color); next_color = xfce_rc_read_int_entry(settings_ro, "next_color", next_color); viewer_text_overlay_enabled = xfce_rc_read_bool_entry(settings_ro, "viewer_text_overlay_enabled", viewer_text_overlay_enabled); viewer_text_overlay_format_string = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_format_string", viewer_text_overlay_format_string.c_str()); viewer_text_overlay_separator = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_separator", viewer_text_overlay_separator.c_str()); viewer_text_overlay_font = xfce_rc_read_entry(settings_ro, "viewer_text_overlay_font", viewer_text_overlay_font.c_str()); viewer_text_overlay_color = xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_color", viewer_text_overlay_color); viewer_monitor_type_sync_enabled = xfce_rc_read_bool_entry(settings_ro, "viewer_monitor_type_sync_enabled", viewer_monitor_type_sync_enabled); // Enum is validated in set_viewer_text_overlay_position CanvasView::TextOverlayPosition text_overlay_position = static_cast<CanvasView::TextOverlayPosition>( xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_position", CanvasView::top_left)); set_viewer_text_overlay_position(text_overlay_position); } // Loading icon try { icon = Gdk::Pixbuf::create_from_file(icon_path); } catch (...) { std::cerr << String::ucompose(_("Hardware Monitor: cannot load the icon '%1'.\n"), icon_path); // It's a minor problem if we can't find the icon icon = Glib::RefPtr<Gdk::Pixbuf>(); } // Configuring viewer type viewer_type_listener(viewer_type); /* Actually setting the viewer size has no effect in this function - * seems that it needs to be done in or after the mainloop kicks off */ // Loading up monitors /* Plugin& is initialised from non-transient address of this ('this' itself * is an rvalue so not allowed for a reference) */ monitor_seq mon = load_monitors(settings_ro, *this); for (monitor_iter i = mon.begin(), end = mon.end(); i != end; ++i) add_monitor(*i); // All settings loaded if (settings_ro) xfce_rc_close(settings_ro); /* Connect plugin signals to functions - since I'm not really interested * in the plugin but the plugin pointer, swapped results in the signal * handler getting the plugin reference first - the plugin pointer is * passed next, but since the handler only takes one parameter this is * discarded * Providing About option */ g_signal_connect_swapped(xfce_plugin, "about", G_CALLBACK(display_about), this); // Hooking into Properties option g_signal_connect_swapped(xfce_plugin, "configure-plugin", G_CALLBACK(display_preferences), this); // Hooking into plugin destruction signal g_signal_connect_swapped(xfce_plugin, "free-data", G_CALLBACK(plugin_free), this); // Hooking into save signal g_signal_connect_swapped(xfce_plugin, "save", G_CALLBACK(save_monitors), this); /* Not needed as the canvas resizes on the fly // Hooking into size changed signal g_signal_connect(xfce_plugin, "size-changed", G_CALLBACK(size_changed), this); */ // Adding configure and about to the plugin's right-click menu xfce_panel_plugin_menu_show_configure(xfce_plugin); xfce_panel_plugin_menu_show_about(xfce_plugin); /* Add plugin to panel - I need to turn the Plugin (which inherits from * Gtk::EventBox) into a GtkWidget* - to do this I get at the GObject * pointer underneath the gtkmm layer */ gtk_container_add(GTK_CONTAINER(xfce_plugin), GTK_WIDGET(this->gobj())); // Initialising timer to run every second (by default) to trigger main_loop timer = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Plugin::main_loop), update_interval); // Initial main_loop run main_loop(); }
void nautilus_launch_desktop_file (GdkScreen *screen, const char *desktop_file_uri, const GList *parameter_uris, GtkWindow *parent_window) { GError *error; char *message, *desktop_file_path; const GList *p; GList *files; int total, count; GFile *file, *desktop_file; GDesktopAppInfo *app_info; GdkAppLaunchContext *context; /* Don't allow command execution from remote locations * to partially mitigate the security * risk of executing arbitrary commands. */ desktop_file = g_file_new_for_uri (desktop_file_uri); desktop_file_path = g_file_get_path (desktop_file); if (!g_file_is_native (desktop_file)) { g_free (desktop_file_path); g_object_unref (desktop_file); eel_show_error_dialog (_("Sorry, but you cannot execute commands from " "a remote site."), _("This is disabled due to security considerations."), parent_window); return; } g_object_unref (desktop_file); app_info = g_desktop_app_info_new_from_filename (desktop_file_path); g_free (desktop_file_path); if (app_info == NULL) { eel_show_error_dialog (_("There was an error launching the application."), NULL, parent_window); return; } /* count the number of uris with local paths */ count = 0; total = g_list_length ((GList *) parameter_uris); files = NULL; for (p = parameter_uris; p != NULL; p = p->next) { file = g_file_new_for_uri ((const char *) p->data); if (g_file_is_native (file)) { count++; } files = g_list_prepend (files, file); } /* check if this app only supports local files */ if (g_app_info_supports_files (G_APP_INFO (app_info)) && !g_app_info_supports_uris (G_APP_INFO (app_info)) && parameter_uris != NULL) { if (count == 0) { /* all files are non-local */ eel_show_error_dialog (_("This drop target only supports local files."), _("To open non-local files copy them to a local folder and then" " drop them again."), parent_window); g_list_free_full (files, g_object_unref); g_object_unref (app_info); return; } else if (count != total) { /* some files are non-local */ eel_show_warning_dialog (_("This drop target only supports local files."), _("To open non-local files copy them to a local folder and then" " drop them again. The local files you dropped have already been opened."), parent_window); } } error = NULL; context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (parent_window))); /* TODO: Ideally we should accept a timestamp here instead of using GDK_CURRENT_TIME */ gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME); gdk_app_launch_context_set_screen (context, gtk_window_get_screen (parent_window)); if (count == total) { /* All files are local, so we can use g_app_info_launch () with * the file list we constructed before. */ g_app_info_launch (G_APP_INFO (app_info), files, G_APP_LAUNCH_CONTEXT (context), &error); } else { /* Some files are non local, better use g_app_info_launch_uris (). */ g_app_info_launch_uris (G_APP_INFO (app_info), (GList *) parameter_uris, G_APP_LAUNCH_CONTEXT (context), &error); } if (error != NULL) { message = g_strconcat (_("Details: "), error->message, NULL); eel_show_error_dialog (_("There was an error launching the application."), message, parent_window); g_error_free (error); g_free (message); } g_list_free_full (files, g_object_unref); g_object_unref (context); g_object_unref (app_info); }
static gboolean panel_struts_allocate_struts (PanelToplevel *toplevel, GdkScreen *screen, int monitor) { GSList *allocated = NULL; GSList *l; gboolean toplevel_changed = FALSE; for (l = panel_struts_list; l; l = l->next) { PanelStrut *strut = l->data; PanelStrut *overlap; GdkRectangle geometry; int monitor_x, monitor_y; int monitor_width, monitor_height; gboolean moved_down; int skip; if (strut->screen != screen || strut->monitor != monitor) continue; panel_struts_get_monitor_geometry (strut->screen, strut->monitor, &monitor_x, &monitor_y, &monitor_width, &monitor_height); strut->allocated_strut_size = strut->strut_size; strut->allocated_strut_start = strut->strut_start; strut->allocated_strut_end = strut->strut_end; geometry = strut->geometry; moved_down = FALSE; skip = 0; while ((overlap = panel_struts_intersect (allocated, &geometry, skip))) skip = panel_struts_allocation_overlapped ( strut, overlap, &geometry, &moved_down, skip); if (strut->orientation & PANEL_VERTICAL_MASK) { if (geometry.y < monitor_y) { geometry.height = geometry.y + geometry.height - monitor_y; geometry.y = monitor_y; } if (geometry.y + geometry.height > monitor_y + monitor_height) geometry.height = monitor_y + monitor_height - geometry.y; } if (strut->allocated_geometry.x != geometry.x || strut->allocated_geometry.y != geometry.y || strut->allocated_geometry.width != geometry.width || strut->allocated_geometry.height != geometry.height) { strut->allocated_geometry = geometry; if (strut->toplevel == toplevel) toplevel_changed = TRUE; else gtk_widget_queue_resize (GTK_WIDGET (strut->toplevel)); } allocated = g_slist_append (allocated, strut); } g_slist_free (allocated); return toplevel_changed; }
void panel_struts_set_window_hint (PanelToplevel *toplevel) { GtkWidget *widget; PanelStrut *strut; int strut_size; int monitor_x, monitor_y, monitor_width, monitor_height; int screen_width, screen_height; int leftmost, rightmost, topmost, bottommost; widget = GTK_WIDGET (toplevel); if (!gtk_widget_get_realized (widget)) return; if (!(strut = panel_struts_find_strut (toplevel))) { panel_struts_unset_window_hint (toplevel); return; } strut_size = strut->allocated_strut_size; screen_width = gdk_screen_get_width (strut->screen); screen_height = gdk_screen_get_height (strut->screen); panel_struts_get_monitor_geometry (strut->screen, strut->monitor, &monitor_x, &monitor_y, &monitor_width, &monitor_height); panel_multiscreen_is_at_visible_extreme (strut->monitor, &leftmost, &rightmost, &topmost, &bottommost); switch (strut->orientation) { case PANEL_ORIENTATION_TOP: if (monitor_y > 0) strut_size += monitor_y; if (!topmost) strut_size = 0; break; case PANEL_ORIENTATION_BOTTOM: if (monitor_y + monitor_height < screen_height) strut_size += screen_height - (monitor_y + monitor_height); if (!bottommost) strut_size = 0; break; case PANEL_ORIENTATION_LEFT: if (leftmost && monitor_x > 0) strut_size += monitor_x; if (!leftmost) strut_size = 0; break; case PANEL_ORIENTATION_RIGHT: if (monitor_x + monitor_width < screen_width) strut_size += screen_width - (monitor_x + monitor_width); if (!rightmost) strut_size = 0; break; default: g_assert_not_reached (); break; } panel_xutils_set_strut (gtk_widget_get_window (widget), strut->orientation, strut_size, strut->allocated_strut_start, strut->allocated_strut_end); }
YC20UI2::YC20UI2() { drawingArea = GTK_WIDGET(gtk_drawing_area_new()); gtk_widget_ref(drawingArea); memset(draggablePerLV2Port, 0, sizeof(Wdgt::Draggable *)*27); // Gtk signals g_signal_connect (drawingArea, "size-request", G_CALLBACK( lv2ui_size_request ), this); g_signal_connect (drawingArea, "size-allocate", G_CALLBACK( lv2ui_size_allocate ), this); g_signal_connect (drawingArea, "expose-event", G_CALLBACK( lv2ui_expose_event ), this); g_signal_connect (drawingArea, "motion-notify-event", G_CALLBACK( lv2ui_motion_notify_event ), this); g_signal_connect (drawingArea, "button-press-event", G_CALLBACK( lv2ui_button_press_event ), this); g_signal_connect (drawingArea, "button-release-event", G_CALLBACK( lv2ui_button_release_event ), this); g_signal_connect (drawingArea, "destroy", G_CALLBACK( lv2ui_destroy_widget ), this); // Event mask gint mask = gtk_widget_get_events(drawingArea); mask |= GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK; gtk_widget_set_events(drawingArea, mask); int c_idx = 3; // Pitch, volume & bass volume Wdgt::Draggable *pitch = wdgtPerLabel["pitch"]; pitch->setPortIndex(c_idx++); Wdgt::Draggable *volume = wdgtPerLabel["volume"]; volume->setPortIndex(c_idx++); Wdgt::Draggable *bass_v = wdgtPerLabel["bass volume"]; bass_v->setPortIndex(c_idx++); // Vibrato section // Instead of the touch vibrato, we have a realism switch Wdgt::Draggable *realism = wdgtPerLabel["realism"]; realism->setPortIndex(c_idx++); Wdgt::Draggable *vibrato = wdgtPerLabel["depth"]; vibrato->setPortIndex(c_idx++); Wdgt::Draggable *v_speed = wdgtPerLabel["speed"]; v_speed->setPortIndex(c_idx++); // Bass Wdgt::Draggable *bass_16 = wdgtPerLabel["16' b"]; bass_16->setPortIndex(c_idx++); Wdgt::Draggable *bass_8 = wdgtPerLabel["8' b"]; bass_8->setPortIndex(c_idx++); Wdgt::Draggable *bass_man = wdgtPerLabel["bass manual"]; bass_man->setPortIndex(c_idx++); // Section I Wdgt::Draggable *sect1_16 = wdgtPerLabel["16' i"]; sect1_16->setPortIndex(c_idx++); Wdgt::Draggable *sect1_8 = wdgtPerLabel["8' i"]; sect1_8->setPortIndex(c_idx++); Wdgt::Draggable *sect1_4 = wdgtPerLabel["4' i"]; sect1_4->setPortIndex(c_idx++); Wdgt::Draggable *sect1_2_2p3 = wdgtPerLabel["2 2/3' i"]; sect1_2_2p3->setPortIndex(c_idx++); Wdgt::Draggable *sect1_2 = wdgtPerLabel["2' i"]; sect1_2->setPortIndex(c_idx++); Wdgt::Draggable *sect1_1_3p5 = wdgtPerLabel["1 3/5' i"]; sect1_1_3p5->setPortIndex(c_idx++); Wdgt::Draggable *sect1_1 = wdgtPerLabel["1' i"]; sect1_1->setPortIndex(c_idx++); // Balance & Brightness Wdgt::Draggable *balance = wdgtPerLabel["balance"]; balance->setPortIndex(c_idx++); Wdgt::Draggable *brightness = wdgtPerLabel["bright"]; brightness->setPortIndex(c_idx++); // Section II Wdgt::Draggable *sect2_16 = wdgtPerLabel["16' ii"]; sect2_16->setPortIndex(c_idx++); Wdgt::Draggable *sect2_8 = wdgtPerLabel["8' ii"]; sect2_8->setPortIndex(c_idx++); Wdgt::Draggable *sect2_4 = wdgtPerLabel["4' ii"]; sect2_4->setPortIndex(c_idx++); Wdgt::Draggable *sect2_2 = wdgtPerLabel["2' ii"]; sect2_2->setPortIndex(c_idx++); // Percussion Wdgt::Draggable *percussive = wdgtPerLabel["percussive"]; percussive->setPortIndex(c_idx++); for (std::list<Wdgt::Draggable *>::iterator i = wdgts.begin(); i != wdgts.end(); ++i) { Wdgt::Draggable *draggable = (*i); draggablePerLV2Port[ draggable->getPortIndex() ] = draggable; } }
static void _lib_modulelist_gui_update(struct dt_lib_module_t *module) { gtk_widget_queue_draw(GTK_WIDGET(((dt_lib_modulelist_t *)module->data)->tree)); }
static void _lib_modulelist_populate_callback(gpointer instance, gpointer user_data) { dt_lib_module_t *self = (dt_lib_module_t *)user_data; if(!self || !(self->data)) return; GtkListStore *store; GtkTreeIter iter; GtkWidget *view = GTK_WIDGET(((dt_lib_modulelist_t *)self->data)->tree); GtkCellRenderer *pix_renderer, *fav_renderer, *text_renderer; GdkRGBA color; GtkStyleContext *context = gtk_widget_get_style_context(view); gboolean color_found = gtk_style_context_lookup_color (context, "selected_bg_color", &color); if(!color_found) { color.red = 1.0; color.green = 0.0; color.blue = 0.0; color.alpha = 1.0; } store = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_POINTER); gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); g_object_unref(store); gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), COL_MODULE, _lib_modulelist_gui_sort, NULL, NULL); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_MODULE, GTK_SORT_ASCENDING); pix_renderer = gtk_cell_renderer_pixbuf_new(); g_object_set(pix_renderer, "cell-background-rgba", &color, NULL); fav_renderer = gtk_cell_renderer_pixbuf_new(); cairo_surface_t *fav_cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ICON_SIZE, ICON_SIZE); cairo_t *fav_cr = cairo_create(fav_cst); cairo_set_source_rgb(fav_cr, 0.7, 0.7, 0.7); dtgtk_cairo_paint_modulegroup_favorites(fav_cr, 0, 0, ICON_SIZE, ICON_SIZE, 0); guchar *data = cairo_image_surface_get_data(fav_cst); dt_draw_cairo_to_gdk_pixbuf(data, ICON_SIZE, ICON_SIZE); ((dt_lib_modulelist_t *)self->data)->fav_pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, 8, ICON_SIZE, ICON_SIZE, cairo_image_surface_get_stride(fav_cst), NULL, NULL); g_object_set(fav_renderer, "cell-background-rgba", &color, NULL); g_object_set(fav_renderer, "width", gdk_pixbuf_get_width(((dt_lib_modulelist_t *)self->data)->fav_pixbuf), NULL); text_renderer = gtk_cell_renderer_text_new(); g_object_set(text_renderer, "cell-background-rgba", &color, NULL); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), FALSE); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); GtkTreeViewColumn *col; col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0); if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col); gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 0, "favorite", fav_renderer, favorite_renderer_function, NULL, NULL); col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 1); if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col); gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 1, "image", pix_renderer, image_renderer_function, NULL, NULL); col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 2); if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col); gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 2, "name", text_renderer, text_renderer_function, NULL, NULL); /* go thru list of iop modules and add them to the list */ GList *modules = g_list_last(darktable.iop); char datadir[PATH_MAX] = { 0 }; dt_loc_get_datadir(datadir, sizeof(datadir)); while(modules) { dt_iop_module_so_t *module = (dt_iop_module_so_t *)(modules->data); if(!dt_iop_so_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED)) { GdkPixbuf *pixbuf; char filename[PATH_MAX] = { 0 }; snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.svg", datadir, module->op); pixbuf = load_image(filename); if(pixbuf) goto end; snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op); pixbuf = load_image(filename); if(pixbuf) goto end; snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.svg", datadir); pixbuf = load_image(filename); if(pixbuf) goto end; snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.png", datadir); pixbuf = load_image(filename); if(pixbuf) goto end; // wow, we could neither load the SVG nor the PNG files. something is f****d up. pixbuf = gdk_pixbuf_new_from_data(fallback_pixel, GDK_COLORSPACE_RGB, TRUE, 8, 1, 1, 4, NULL, NULL); end: gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, COL_IMAGE, pixbuf, COL_MODULE, module, -1); g_object_unref(pixbuf); } modules = g_list_previous(modules); } }
static gboolean get_child_position (GtkOverlay *overlay, GtkWidget *widget, GtkAllocation *allocation, GtkColorEditor *editor) { GtkRequisition req; GtkAllocation alloc; gint s, e; gtk_widget_get_preferred_size (widget, &req, NULL); allocation->x = 0; allocation->y = 0; allocation->width = req.width; allocation->height = req.height; if (widget == editor->priv->sv_popup) { gtk_widget_translate_coordinates (editor->priv->sv_plane, gtk_widget_get_parent (editor->priv->grid), 0, -6, &allocation->x, &allocation->y); if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL) allocation->x = 0; else allocation->x = gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width; } else if (widget == editor->priv->h_popup) { gtk_widget_get_allocation (editor->priv->h_slider, &alloc); gtk_range_get_slider_range (GTK_RANGE (editor->priv->h_slider), &s, &e); if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL) gtk_widget_translate_coordinates (editor->priv->h_slider, gtk_widget_get_parent (editor->priv->grid), - req.width - 6, editor->priv->popup_position - req.height / 2, &allocation->x, &allocation->y); else gtk_widget_translate_coordinates (editor->priv->h_slider, gtk_widget_get_parent (editor->priv->grid), alloc.width + 6, editor->priv->popup_position - req.height / 2, &allocation->x, &allocation->y); } else if (widget == editor->priv->a_popup) { gtk_widget_get_allocation (editor->priv->a_slider, &alloc); gtk_range_get_slider_range (GTK_RANGE (editor->priv->a_slider), &s, &e); gtk_widget_translate_coordinates (editor->priv->a_slider, gtk_widget_get_parent (editor->priv->grid), editor->priv->popup_position - req.width / 2, - req.height - 6, &allocation->x, &allocation->y); } else return FALSE; allocation->x = CLAMP (allocation->x, 0, gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width); allocation->y = CLAMP (allocation->y, 0, gtk_widget_get_allocated_height (GTK_WIDGET (overlay)) - req.height); return TRUE; }
void nautilus_launch_application_by_uri (GAppInfo *application, GList *uris, GtkWindow *parent_window) { char *uri; GList *locations, *l; GFile *location; NautilusFile *file; gboolean result; GError *error; GdkDisplay *display; GdkAppLaunchContext *launch_context; NautilusIconInfo *icon; int count, total; g_assert (uris != NULL); /* count the number of uris with local paths */ count = 0; total = g_list_length (uris); locations = NULL; for (l = uris; l != NULL; l = l->next) { uri = l->data; location = g_file_new_for_uri (uri); if (g_file_is_native (location)) { count++; } locations = g_list_prepend (locations, location); } locations = g_list_reverse (locations); if (parent_window != NULL) { display = gtk_widget_get_display (GTK_WIDGET (parent_window)); } else { display = gdk_display_get_default (); } launch_context = gdk_display_get_app_launch_context (display); if (parent_window != NULL) { gdk_app_launch_context_set_screen (launch_context, gtk_window_get_screen (parent_window)); } file = nautilus_file_get_by_uri (uris->data); icon = nautilus_file_get_icon (file, 48, gtk_widget_get_scale_factor (GTK_WIDGET (parent_window)), 0); nautilus_file_unref (file); if (icon) { gdk_app_launch_context_set_icon_name (launch_context, nautilus_icon_info_get_used_name (icon)); g_object_unref (icon); } error = NULL; if (count == total) { /* All files are local, so we can use g_app_info_launch () with * the file list we constructed before. */ result = g_app_info_launch (application, locations, G_APP_LAUNCH_CONTEXT (launch_context), &error); } else { /* Some files are non local, better use g_app_info_launch_uris (). */ result = g_app_info_launch_uris (application, uris, G_APP_LAUNCH_CONTEXT (launch_context), &error); } g_object_unref (launch_context); if (result) { for (l = uris; l != NULL; l = l->next) { file = nautilus_file_get_by_uri (l->data); nautilus_recent_add_file (file, application); nautilus_file_unref (file); } } g_list_free_full (locations, g_object_unref); }
static void on_operations_icon_draw (GtkWidget *widget, cairo_t *cr, NautilusToolbar *self) { gfloat elapsed_progress = 0; gint remaining_progress = 0; gint total_progress; gdouble ratio; GList *progress_infos; GList *l; guint width; guint height; gboolean all_cancelled; GdkRGBA background = {.red = 0, .green = 0, .blue = 0, .alpha = 0.2 }; GdkRGBA foreground = {.red = 0, .green = 0, .blue = 0, .alpha = 0.7 }; all_cancelled = TRUE; progress_infos = nautilus_progress_info_manager_get_all_infos (self->priv->progress_manager); for (l = progress_infos; l != NULL; l = l->next) { if (!nautilus_progress_info_get_is_cancelled (l->data)) { all_cancelled = FALSE; remaining_progress += nautilus_progress_info_get_remaining_time (l->data); elapsed_progress += nautilus_progress_info_get_elapsed_time (l->data); } } total_progress = remaining_progress + elapsed_progress; if (all_cancelled) { ratio = 1.0; } else { if (total_progress > 0) { ratio = MAX (0.05, elapsed_progress / total_progress); } else { ratio = 0.05; } } width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); gdk_cairo_set_source_rgba(cr, &background); cairo_arc (cr, width / 2.0, height / 2.0, MIN (width, height) / 2.0, 0, 2 *G_PI); cairo_fill (cr); cairo_move_to (cr, width / 2.0, height / 2.0); gdk_cairo_set_source_rgba (cr, &foreground); cairo_arc (cr, width / 2.0, height / 2.0, MIN (width, height) / 2.0, -G_PI / 2.0, ratio * 2 * G_PI - G_PI / 2.0); cairo_fill (cr); } static void on_operations_button_toggled (NautilusToolbar *self) { unschedule_remove_finished_operations (self); if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->operations_button))) { schedule_remove_finished_operations (self); } else { update_operations (self); } } static void nautilus_toolbar_init (NautilusToolbar *self) { GtkBuilder *builder; self->priv = nautilus_toolbar_get_instance_private (self); gtk_widget_init_template (GTK_WIDGET (self)); self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL); gtk_container_add (GTK_CONTAINER (self->priv->path_bar_container), self->priv->path_bar); self->priv->location_entry = nautilus_location_entry_new (); gtk_container_add (GTK_CONTAINER (self->priv->location_entry_container), self->priv->location_entry); builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-toolbar-view-menu.xml"); self->priv->view_menu_widget = GTK_WIDGET (gtk_builder_get_object (builder, "view_menu_widget")); self->priv->zoom_level_scale = GTK_WIDGET (gtk_builder_get_object (builder, "zoom_level_scale")); self->priv->zoom_adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (builder, "zoom_adjustment")); self->priv->sort_menu = GTK_WIDGET (gtk_builder_get_object (builder, "sort_menu")); self->priv->sort_trash_time = GTK_WIDGET (gtk_builder_get_object (builder, "sort_trash_time")); self->priv->sort_search_relevance = GTK_WIDGET (gtk_builder_get_object (builder, "sort_search_relevance")); self->priv->visible_columns = GTK_WIDGET (gtk_builder_get_object (builder, "visible_columns")); self->priv->reload = GTK_WIDGET (gtk_builder_get_object (builder, "reload")); self->priv->stop = GTK_WIDGET (gtk_builder_get_object (builder, "stop")); g_signal_connect (self->priv->view_menu_widget, "closed", G_CALLBACK (view_menu_popover_closed), self); gtk_menu_button_set_popover (GTK_MENU_BUTTON (self->priv->view_button), self->priv->view_menu_widget); g_object_unref (builder); builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-toolbar-action-menu.xml"); self->priv->action_menu = G_MENU (gtk_builder_get_object (builder, "action-menu")); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (self->priv->action_button), G_MENU_MODEL (self->priv->action_menu)); g_object_unref (builder); self->priv->progress_manager = nautilus_progress_info_manager_dup_singleton (); g_signal_connect (self->priv->progress_manager, "new-progress-info", G_CALLBACK (on_new_progress_info), self); update_operations (self); g_object_set_data (G_OBJECT (self->priv->back_button), "nav-direction", GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_BACK)); g_object_set_data (G_OBJECT (self->priv->forward_button), "nav-direction", GUINT_TO_POINTER (NAUTILUS_NAVIGATION_DIRECTION_FORWARD)); g_signal_connect (self->priv->back_button, "button-press-event", G_CALLBACK (navigation_button_press_cb), self); g_signal_connect (self->priv->back_button, "button-release-event", G_CALLBACK (navigation_button_release_cb), self); g_signal_connect (self->priv->forward_button, "button-press-event", G_CALLBACK (navigation_button_press_cb), self); g_signal_connect (self->priv->forward_button, "button-release-event", G_CALLBACK (navigation_button_release_cb), self); g_signal_connect (self->priv->zoom_level_scale, "value-changed", G_CALLBACK (zoom_level_changed), self); gtk_widget_show_all (GTK_WIDGET (self)); toolbar_update_appearance (self); }
void views_finalize(void) { gtk_widget_destroy(GTK_WIDGET(command_dialog)); }
static GtkWidget * build_table (GtkWidget *container, GKeyFile *key_file, GtkSizeGroup *label_size_group, GList *entries) { GtkWidget *table; GtkWidget *label; GtkWidget *entry; GList *l; char *val; int i; table = gtk_table_new (g_list_length (entries) + 1, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); i = 0; for (l = entries; l; l = l->next) { ItemEntry *item_entry = (ItemEntry *)l->data; char *label_text; label_text = g_strdup_printf ("%s:", item_entry->description); label = gtk_label_new (label_text); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); g_free (label_text); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_size_group_add_widget (label_size_group, label); entry = gtk_entry_new (); if (item_entry->localized) { val = g_key_file_get_locale_string (key_file, MAIN_GROUP, item_entry->field, NULL, NULL); } else { val = g_key_file_get_string (key_file, MAIN_GROUP, item_entry->field, NULL); } item_entry->current_value = g_strdup (val?val:""); gtk_entry_set_text (GTK_ENTRY (entry), item_entry->current_value); g_free (val); gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), entry, 1, 2, i, i+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 0); g_signal_connect (entry, "activate", G_CALLBACK (entry_activate_cb), container); g_signal_connect (entry, "focus_out_event", G_CALLBACK (entry_focus_out_cb), container); g_object_set_data_full (G_OBJECT (entry), "item_entry", item_entry, (GDestroyNotify)item_entry_free); if (item_entry->filename) { gtk_drag_dest_set (GTK_WIDGET (entry), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (entry, "drag_data_received", G_CALLBACK (fm_ditem_page_url_drag_data_received), entry); } else if (strcmp (item_entry->field, "Exec") == 0) { gtk_drag_dest_set (GTK_WIDGET (entry), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); g_signal_connect (entry, "drag_data_received", G_CALLBACK (fm_ditem_page_exec_drag_data_received), entry); } i++; } /* append dummy row */ label = gtk_label_new (""); gtk_table_attach (GTK_TABLE (table), label, 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0); gtk_size_group_add_widget (label_size_group, label); gtk_widget_show_all (table); return table; }
void FormDialog::multiple_choice (const std::string name, const std::string description, const std::set<std::string> values, const std::map<std::string, std::string> choices, bool advanced) { GtkWidget *label = NULL; GtkWidget *scroll = NULL; GtkWidget *tree_view = NULL; GtkWidget *frame = NULL; GtkListStore *list_store = NULL; GtkTreeViewColumn *column = NULL; GtkCellRenderer *renderer = NULL; GtkTreeIter iter; gchar *label_text = NULL; MultipleChoiceSubmitter *submitter = NULL; grow_fields (advanced); /* The label */ label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); label_text = g_strdup_printf ("<b>%s</b>", description.c_str()); gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), label_text); g_free (label_text); /* The GtkListStore containing the choices */ tree_view = gtk_tree_view_new (); list_store = gtk_list_store_new (MultipleChoiceSubmitter::COLUMN_NUMBER, G_TYPE_BOOLEAN, G_TYPE_STRING); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); frame = gtk_frame_new (NULL); gtk_widget_set_size_request (GTK_WIDGET (frame), -1, 125); gtk_container_set_border_width (GTK_CONTAINER (frame), 0); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (frame), scroll); gtk_container_add (GTK_CONTAINER (scroll), tree_view); renderer = gtk_cell_renderer_toggle_new (); column = gtk_tree_view_column_new_with_attributes (NULL, renderer, "active", MultipleChoiceSubmitter::COLUMN_ACTIVE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); g_signal_connect (renderer, "toggled", G_CALLBACK (multiple_choice_choice_toggled_cb), list_store); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (NULL, renderer, "text", MultipleChoiceSubmitter::COLUMN_NAME, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); for (std::map<std::string, std::string>::const_iterator map_iter = choices.begin (); map_iter != choices.end (); map_iter++) { bool active = (std::find (values.begin (), values.end (), map_iter->first) != values.end ()); gtk_list_store_append (GTK_LIST_STORE (list_store), &iter); gtk_list_store_set (GTK_LIST_STORE (list_store), &iter, MultipleChoiceSubmitter::COLUMN_ACTIVE, active, MultipleChoiceSubmitter::COLUMN_NAME, map_iter->second.c_str (), -1); } if (advanced) { gtk_table_attach (GTK_TABLE (advanced_fields), label, 0, 2, advanced_rows - 1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); gtk_table_attach (GTK_TABLE (advanced_fields), frame, 0, 2, advanced_rows - 1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } else { gtk_table_attach (GTK_TABLE (fields), label, 0, 2, rows - 1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); gtk_table_attach (GTK_TABLE (fields), frame, 0, 2, rows - 1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } submitter = new MultipleChoiceSubmitter (name, description, choices, advanced, tree_view); submitters.push_back (submitter); }
GtkWidget *ryosconfig_key_illumination_selector_new(void) { return GTK_WIDGET(g_object_new(RYOSCONFIG_KEY_ILLUMINATION_SELECTOR_TYPE, NULL)); }
void FormDialog::editable_set (const std::string name, const std::string description, const std::set<std::string> values, const std::set<std::string> proposed_values, bool advanced) { GtkWidget *label = NULL; GtkWidget *scroll = NULL; GtkWidget *button = NULL; GtkWidget *tree_view = NULL; GtkWidget *frame = NULL; GtkWidget *hbox = NULL; GtkWidget *entry = NULL; GtkListStore *list_store = NULL; GtkTreeViewColumn *column = NULL; GtkCellRenderer *renderer = NULL; GtkTreeIter iter; gchar *label_text = NULL; EditableSetSubmitter *submitter = NULL; /* The label */ label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); label_text = g_strdup_printf ("<b>%s</b>", description.c_str()); gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), label_text); g_free (label_text); /* The GtkListStore containing the values */ list_store = gtk_list_store_new (EditableSetSubmitter::COLUMN_NUMBER, G_TYPE_BOOLEAN, G_TYPE_STRING); tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); frame = gtk_frame_new (NULL); gtk_widget_set_size_request (GTK_WIDGET (frame), -1, 125); gtk_container_set_border_width (GTK_CONTAINER (frame), 0); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (frame), scroll); gtk_container_add (GTK_CONTAINER (scroll), tree_view); renderer = gtk_cell_renderer_toggle_new (); column = gtk_tree_view_column_new_with_attributes (NULL, renderer, "active", EditableSetSubmitter::COLUMN_ACTIVE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); g_signal_connect (renderer, "toggled", G_CALLBACK (editable_set_choice_toggled_cb), list_store); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (NULL, renderer, "text", EditableSetSubmitter::COLUMN_VALUE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); for (std::set<std::string>::const_iterator set_iter = values.begin (); set_iter != values.end (); set_iter++) { gtk_list_store_append (GTK_LIST_STORE (list_store), &iter); gtk_list_store_set (GTK_LIST_STORE (list_store), &iter, EditableSetSubmitter::COLUMN_ACTIVE, TRUE, EditableSetSubmitter::COLUMN_VALUE, set_iter->c_str (), -1); } for (std::set<std::string>::const_iterator set_iter = proposed_values.begin (); set_iter != proposed_values.end (); set_iter++) { if (values.find (*set_iter) == values.end ()) { gtk_list_store_append (GTK_LIST_STORE (list_store), &iter); gtk_list_store_set (GTK_LIST_STORE (list_store), &iter, EditableSetSubmitter::COLUMN_ACTIVE, FALSE, EditableSetSubmitter::COLUMN_VALUE, set_iter->c_str (), -1); } } if (advanced) { grow_fields (advanced); gtk_table_attach (GTK_TABLE (advanced_fields), label, 0, 2, advanced_rows - 1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); grow_fields (advanced); gtk_table_attach (GTK_TABLE (advanced_fields), frame, 0, 2, advanced_rows - 1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } else { grow_fields (advanced); gtk_table_attach (GTK_TABLE (fields), label, 0, 2, rows - 1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); grow_fields (advanced); gtk_table_attach (GTK_TABLE (fields), frame, 0, 2, rows - 1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } hbox = gtk_hbox_new (FALSE, 2); entry = gtk_entry_new (); button = gtk_button_new_from_stock (GTK_STOCK_ADD); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 2); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 2); g_signal_connect (entry, "activate", (GCallback) editable_set_add_value_activated_cb, (gpointer) tree_view); g_signal_connect (button, "clicked", (GCallback) editable_set_add_value_clicked_cb, (gpointer) entry); grow_fields (advanced); if (advanced) { gtk_table_attach (GTK_TABLE (advanced_fields), hbox, 0, 2, advanced_rows - 1, advanced_rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } else { gtk_table_attach (GTK_TABLE (fields), hbox, 0, 2, rows - 1, rows, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), (GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0); } submitter = new EditableSetSubmitter (name, description, advanced, tree_view); submitters.push_back (submitter); }
static gboolean update_monitors(t_global_monitor *global) { char buffer[SUM+1][BUFSIZ]; gchar caption[BUFSIZ]; gulong net[SUM+1]; gulong display[SUM+1], max; guint64 histcalculate; double temp; gint i, j; get_current_netload( &(global->monitor->data), &(net[IN]), &(net[OUT]), &(net[TOT]) ); for (i = 0; i < SUM; i++) { /* correct value to be from 1 ... 100 */ global->monitor->history[i][0] = net[i]; if (global->monitor->history[i][0] < 0) { global->monitor->history[i][0] = 0; } histcalculate = 0; for( j = 0; j < HISTSIZE_CALCULATE; j++ ) { histcalculate += global->monitor->history[i][j]; } display[i] = histcalculate / HISTSIZE_CALCULATE; /* shift for next run */ for( j = HISTSIZE_STORE - 1; j > 0; j-- ) { global->monitor->history[i][j] = global->monitor->history[i][j-1]; } /* update maximum */ if( global->monitor->options.auto_max ) { max = max_array( global->monitor->history[i], HISTSIZE_STORE ); if( display[i] > global->monitor->net_max[i] ) { global->monitor->net_max[i] = display[i]; } else if( max < global->monitor->net_max[i] * SHRINK_MAX && global->monitor->net_max[i] * SHRINK_MAX >= MINIMAL_MAX ) { global->monitor->net_max[i] *= SHRINK_MAX; } } #ifdef DEBUG switch( i ) { case IN: fprintf( stderr, "input: Max = %lu\n", global->monitor->net_max[i] ); break; case OUT: fprintf( stderr, "output: Max = %lu\n", global->monitor->net_max[i] ); break; case TOT: fprintf( stderr, "total: Max = %lu\n", global->monitor->net_max[i] ); break; } #endif /* DEBUG */ temp = (double)display[i] / global->monitor->net_max[i]; if( temp > 1 ) { temp = 1.0; } else if( temp < 0 ) { temp = 0.0; } gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(global->monitor->status[i]), temp); format_with_thousandssep( buffer[i], BUFSIZ, display[i] / 1024.0, 2 ); } format_with_thousandssep( buffer[TOT], BUFSIZ, (display[IN]+display[OUT]) / 1024, 2 ); g_snprintf(caption, sizeof(caption), _("Average of last %d measures:\n" "Incoming: %s kByte/s\nOutgoing: %s kByte/s\nTotal: %s kByte/s"), HISTSIZE_CALCULATE, buffer[IN], buffer[OUT], buffer[TOT]); gtk_tooltips_set_tip(tooltips, GTK_WIDGET(global->monitor->ebox), caption, NULL); return TRUE; }
void FormDialog::cancel () { gtk_widget_hide (GTK_WIDGET (window)); request->cancel (); }
static void monitor_set_orientation (Control * ctrl, int orientation) { t_global_monitor *global = ctrl->data; GtkRcStyle *rc; gint i; if (global->timeout_id) { g_source_remove(global->timeout_id); } gtk_widget_hide(GTK_WIDGET(global->ebox)); gtk_container_remove(GTK_CONTAINER(global->ebox), GTK_WIDGET(global->box)); if (orientation == HORIZONTAL) { global->box = gtk_hbox_new(FALSE, 0); } else { global->box = gtk_vbox_new(FALSE, 0); } gtk_widget_show(global->box); global->monitor->label = gtk_label_new(global->monitor->options.label_text); gtk_widget_show(global->monitor->label); for (i = 0; i < SUM; i++) { global->monitor->status[i] = GTK_WIDGET(gtk_progress_bar_new()); } if (orientation == HORIZONTAL) { global->monitor->box = GTK_WIDGET(gtk_hbox_new(FALSE, 0)); for (i = 0; i < SUM; i++) { gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]), GTK_PROGRESS_BOTTOM_TO_TOP); } } else { global->monitor->box = GTK_WIDGET(gtk_vbox_new(FALSE, 0)); for (i = 0; i < SUM; i++) { gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]), GTK_PROGRESS_LEFT_TO_RIGHT); } } gtk_box_pack_start(GTK_BOX(global->monitor->box), GTK_WIDGET(global->monitor->label), FALSE, FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(global->monitor->box), border_width); gtk_widget_show(GTK_WIDGET(global->monitor->box)); global->monitor->ebox = gtk_event_box_new(); gtk_widget_show(global->monitor->ebox); gtk_container_add(GTK_CONTAINER(global->monitor->ebox), GTK_WIDGET(global->monitor->box)); for (i = 0; i < SUM; i++) { rc = gtk_widget_get_modifier_style(GTK_WIDGET(global->monitor->status[i])); if (!rc) { rc = gtk_rc_style_new(); } else { rc->color_flags[GTK_STATE_PRELIGHT] |= GTK_RC_BG; rc->bg[GTK_STATE_PRELIGHT] = global->monitor->options.color[i]; } gtk_widget_modify_style(GTK_WIDGET(global->monitor->status[i]), rc); gtk_widget_show(GTK_WIDGET(global->monitor->status[i])); gtk_box_pack_start(GTK_BOX(global->monitor->box), GTK_WIDGET(global->monitor->status[i]), FALSE, FALSE, 0); } gtk_box_pack_start(GTK_BOX(global->box), GTK_WIDGET(global->monitor->ebox), FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(global->ebox), GTK_WIDGET(global->box)); gtk_widget_show(GTK_WIDGET(global->ebox)); run_update( global ); }
GtkDialog* seahorse_passphrase_prompt_show (const gchar *title, const gchar *description, const gchar *prompt, const gchar *check, gboolean confirm) { GtkEntryBuffer *buffer; GtkEntry *entry; GtkDialog *dialog; GtkWidget *w; GtkWidget *box; GtkTable *table; GtkWidget *wvbox; GtkWidget *chbox; gchar *msg; if (!title) title = _("Passphrase"); if (!prompt) prompt = _("Password:"******"size-request", G_CALLBACK (constrain_size), NULL); g_signal_connect (G_OBJECT (dialog), "map-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "unmap-event", G_CALLBACK (ungrab_keyboard), NULL); g_signal_connect (G_OBJECT (dialog), "window-state-event", G_CALLBACK (window_state_changed), NULL); wvbox = gtk_vbox_new (FALSE, HIG_LARGE * 2); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), wvbox); gtk_container_set_border_width (GTK_CONTAINER (wvbox), HIG_LARGE); chbox = gtk_hbox_new (FALSE, HIG_LARGE); gtk_box_pack_start (GTK_BOX (wvbox), chbox, FALSE, FALSE, 0); /* The image */ w = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.0); gtk_box_pack_start (GTK_BOX (chbox), w, FALSE, FALSE, 0); box = gtk_vbox_new (FALSE, HIG_SMALL); gtk_box_pack_start (GTK_BOX (chbox), box, TRUE, TRUE, 0); /* The description text */ if (description) { msg = utf8_validate (description); w = gtk_label_new (msg); g_free (msg); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_label_set_line_wrap (GTK_LABEL (w), TRUE); gtk_box_pack_start (GTK_BOX (box), w, TRUE, FALSE, 0); } /* Two entries (usually on is hidden) in a vbox */ table = GTK_TABLE (gtk_table_new (3, 2, FALSE)); gtk_table_set_row_spacings (table, HIG_SMALL); gtk_table_set_col_spacings (table, HIG_LARGE); gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (table), FALSE, FALSE, 0); /* The first entry if we have one */ if (confirm) { msg = utf8_validate (prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_entry_set_visibility (entry, FALSE); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); g_object_set_data (G_OBJECT (dialog), "confirm-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (confirm_callback), dialog); g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 0, 1); gtk_widget_grab_focus (GTK_WIDGET (entry)); } /* The second and main entry */ msg = utf8_validate (confirm ? _("Confirm:") : prompt); w = gtk_label_new (msg); g_free (msg); gtk_table_attach (table, w, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); buffer = seahorse_secure_buffer_new (); entry = GTK_ENTRY (gtk_entry_new_with_buffer (buffer)); g_object_unref (buffer); gtk_widget_set_size_request (GTK_WIDGET (entry), 200, -1); gtk_entry_set_visibility (entry, FALSE); g_object_set_data (G_OBJECT (dialog), "secure-entry", entry); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), dialog); gtk_table_attach_defaults (table, GTK_WIDGET (entry), 1, 2, 1, 2); if (!confirm) gtk_widget_grab_focus (GTK_WIDGET (entry)); else g_signal_connect (G_OBJECT (entry), "changed", G_CALLBACK (entry_changed), dialog); /* The checkbox */ if (check) { w = gtk_check_button_new_with_mnemonic (check); gtk_table_attach_defaults (table, w, 1, 2, 2, 3); g_object_set_data (G_OBJECT (dialog), "check-option", w); } gtk_widget_show_all (GTK_WIDGET (table)); w = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_REJECT); gtk_widget_set_can_default (w, TRUE); w = gtk_button_new_from_stock (GTK_STOCK_OK); gtk_dialog_add_action_widget (dialog, w, GTK_RESPONSE_ACCEPT); gtk_widget_set_can_default (w, TRUE); g_signal_connect_object (G_OBJECT (entry), "focus_in_event", G_CALLBACK (gtk_widget_grab_default), G_OBJECT (w), 0); gtk_widget_grab_default (w); g_signal_connect (dialog, "key_press_event", G_CALLBACK (key_press), NULL); gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE); gtk_widget_show_all (GTK_WIDGET (dialog)); gdk_window_focus (gtk_widget_get_window (GTK_WIDGET (dialog)), GDK_CURRENT_TIME); if (confirm) entry_changed (NULL, dialog); return dialog; }
static void gnc_ui_file_access( int type ) { FileAccessWindow *faw; GladeXML* xml; GtkWidget* box; GList* ds_node; GtkButton* op; GtkWidget* align; GtkFileChooserWidget* fileChooser; GtkFileChooserAction fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN; GList* list; GList* node; GtkWidget* uri_type_container; gboolean need_access_method_file = FALSE; gboolean need_access_method_mysql = FALSE; gboolean need_access_method_postgres = FALSE; gboolean need_access_method_sqlite3 = FALSE; gboolean need_access_method_xml = FALSE; gint access_method_index = -1; gint active_access_method_index = -1; const gchar* default_db; const gchar *button_label = NULL; g_return_if_fail( type == FILE_ACCESS_OPEN || type == FILE_ACCESS_SAVE_AS ); faw = g_new0(FileAccessWindow, 1); g_return_if_fail( faw != NULL ); faw->type = type; /* Open the dialog */ xml = gnc_glade_xml_new( "dialog-file-access.glade", "File Access" ); faw->dialog = glade_xml_get_widget( xml, "File Access" ); g_object_set_data_full( G_OBJECT(faw->dialog), "FileAccessWindow", faw, g_free ); faw->frame_file = glade_xml_get_widget( xml, "frame_file" ); faw->frame_database = glade_xml_get_widget( xml, "frame_database" ); faw->tf_host = GTK_ENTRY(glade_xml_get_widget( xml, "tf_host" )); gtk_entry_set_text( faw->tf_host, DEFAULT_HOST ); faw->tf_database = GTK_ENTRY(glade_xml_get_widget( xml, "tf_database" )); default_db = get_default_database(); gtk_entry_set_text( faw->tf_database, default_db ); faw->tf_username = GTK_ENTRY(glade_xml_get_widget( xml, "tf_username" )); faw->tf_password = GTK_ENTRY(glade_xml_get_widget( xml, "tf_password" )); switch ( type ) { case FILE_ACCESS_OPEN: gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Open...")); button_label = "gtk-open"; fileChooserAction = GTK_FILE_CHOOSER_ACTION_OPEN; break; case FILE_ACCESS_SAVE_AS: gtk_window_set_title(GTK_WINDOW(faw->dialog), _("Save As...")); button_label = "gtk-save-as"; fileChooserAction = GTK_FILE_CHOOSER_ACTION_SAVE; break; } op = GTK_BUTTON(glade_xml_get_widget( xml, "pb_op" )); if ( op != NULL ) { gtk_button_set_label( op, button_label ); gtk_button_set_use_stock( op, TRUE ); } align = glade_xml_get_widget( xml, "alignment_file_chooser" ); fileChooser = GTK_FILE_CHOOSER_WIDGET(gtk_file_chooser_widget_new( fileChooserAction )); faw->fileChooser = GTK_FILE_CHOOSER(fileChooser); gtk_container_add( GTK_CONTAINER(align), GTK_WIDGET(fileChooser) ); g_object_connect( G_OBJECT(faw->fileChooser), "signal::file-activated", gnc_ui_file_access_file_activated_cb, faw, NULL ); uri_type_container = glade_xml_get_widget( xml, "vb_uri_type_container" ); faw->cb_uri_type = GTK_COMBO_BOX(gtk_combo_box_new_text()); gtk_container_add( GTK_CONTAINER(uri_type_container), GTK_WIDGET(faw->cb_uri_type) ); gtk_box_set_child_packing( GTK_BOX(uri_type_container), GTK_WIDGET(faw->cb_uri_type), /*expand*/TRUE, /*fill*/FALSE, /*padding*/0, GTK_PACK_START ); g_object_connect( G_OBJECT(faw->cb_uri_type), "signal::changed", cb_uri_type_changed_cb, NULL, NULL ); /* Autoconnect signals */ glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, faw->dialog ); /* See what qof backends are available and add appropriate ones to the combo box */ list = qof_backend_get_registered_access_method_list(); for ( node = list; node != NULL; node = node->next ) { const gchar* access_method = node->data; /* For the different access methods, "mysql" and "postgres" are added if available. Access methods "xml" and "sqlite3" are compressed to "file" if opening a file, but when saving a file, both access methods are added. */ if ( strcmp( access_method, "mysql" ) == 0 ) { need_access_method_mysql = TRUE; } else if ( strcmp( access_method, "postgres" ) == 0 ) { need_access_method_postgres = TRUE; } else if ( strcmp( access_method, "xml" ) == 0 ) { if ( type == FILE_ACCESS_OPEN ) { need_access_method_file = TRUE; } else { need_access_method_xml = TRUE; } } else if ( strcmp( access_method, "sqlite3" ) == 0 ) { if ( type == FILE_ACCESS_OPEN ) { need_access_method_file = TRUE; } else { need_access_method_sqlite3 = TRUE; } } } g_list_free(list); /* Now that the set of access methods has been ascertained, add them to the list, and set the default. */ access_method_index = -1; if ( need_access_method_file ) { gtk_combo_box_append_text( faw->cb_uri_type, "file" ); active_access_method_index = ++access_method_index; } if ( need_access_method_mysql ) { gtk_combo_box_append_text( faw->cb_uri_type, "mysql" ); ++access_method_index; } if ( need_access_method_postgres ) { gtk_combo_box_append_text( faw->cb_uri_type, "postgres" ); ++access_method_index; } if ( need_access_method_sqlite3 ) { gtk_combo_box_append_text( faw->cb_uri_type, "sqlite3" ); active_access_method_index = ++access_method_index; } if ( need_access_method_xml ) { gtk_combo_box_append_text( faw->cb_uri_type, "xml" ); ++access_method_index; // Set XML as default if it is offered (which mean we are in // the "Save As" dialog) active_access_method_index = access_method_index; } g_assert( active_access_method_index >= 0 ); /* Clean up the xml data structure when the dialog is destroyed */ g_object_set_data_full( G_OBJECT(faw->dialog), "dialog-file-access.glade", xml, g_object_unref ); /* Run the dialog */ gtk_widget_show_all( faw->dialog ); /* Hide the frame that's not required for the active access method so either only * the File or only the Database frame are presented. */ gtk_combo_box_set_active( faw->cb_uri_type, active_access_method_index ); set_widget_sensitivity_for_uri_type( faw, gtk_combo_box_get_active_text( faw->cb_uri_type ) ); }
static void update_tooltip(GtkTreeView *tv, GtkTreePath *path) { const struct node_data *data = NULL; GtkTreeModel *model; GtkTreeIter iter; g_assert(tv != NULL); if (path) { GtkTreeIter parent; model = gtk_tree_view_get_model(tv); if (!gtk_tree_model_get_iter(model, &iter, path)) { g_warning("gtk_tree_model_get_iter() failed"); return; } if (gtk_tree_model_iter_parent(model, &parent, &iter)) iter = parent; gtk_tree_model_get(model, &iter, 0, &data, (-1)); } if (data && find_node(data->node_id)) { gnet_node_info_t info; gnet_node_flags_t flags; gchar text[1024]; guc_node_fill_flags(data->node_id, &flags); guc_node_fill_info(data->node_id, &info); g_assert(info.node_id == data->node_id); str_bprintf(text, sizeof text, "%s %s\n" "%s %s (%s)\n" "%s %s (%s)\n" "%s %.64s", _("Peer:"), host_addr_port_to_string(info.gnet_addr, info.gnet_port), _("Peermode:"), guc_node_peermode_to_string(flags.peermode), flags.incoming ? _("incoming") : _("outgoing"), _("Country:"), iso3166_country_name(info.country), iso3166_country_cc(info.country), _("Vendor:"), info.vendor ? info.vendor : _("Unknown")); guc_node_clear_info(&info); gtk_tooltips_set_tip(settings_gui_tooltips(), GTK_WIDGET(tv), text, NULL); } else { GtkWidget *w; gtk_tooltips_set_tip(settings_gui_tooltips(), GTK_WIDGET(tv), _("Move the cursor over a row to see details."), NULL); w = settings_gui_tooltips()->tip_window; if (w) gtk_widget_hide(w); } }
inline void inline_draw_sv_plane (HildonColorChooser *sel, int x, int y, int w, int h) { GtkWidget *widget = GTK_WIDGET (sel); unsigned char *buf, *ptr; unsigned long rgbx[3] = { 0x00ffffff, 0x00ffffff, 0x00ffffff }, rgbtmp[3]; signed long rgby[3]; HildonColorChooserPrivate *priv; int i, j; int tmp; if (w <= 0 || h <= 0) { return; } priv = HILDON_COLOR_CHOOSER_GET_PRIVATE (sel); g_assert (priv); tmp = priv->spa.width * priv->spa.height; buf = (unsigned char *) g_malloc (w * h * 3); ptr = buf; inline_h2rgb (priv->currhue, rgbtmp); rgby[0] = rgbtmp[0] - rgbx[0]; rgby[1] = rgbtmp[1] - rgbx[1]; rgby[2] = rgbtmp[2] - rgbx[2]; rgbx[0] /= priv->spa.width; rgbx[1] /= priv->spa.width; rgbx[2] /= priv->spa.width; rgby[0] /= tmp; rgby[1] /= tmp; rgby[2] /= tmp; rgbx[0] += (y - priv->spa.y) * rgby[0]; rgbx[1] += (y - priv->spa.y) * rgby[1]; rgbx[2] += (y - priv->spa.y) * rgby[2]; for(i = 0; i < h; i++) { rgbtmp[0] = rgbx[0] * (x - priv->spa.x); rgbtmp[1] = rgbx[1] * (x - priv->spa.x); rgbtmp[2] = rgbx[2] * (x - priv->spa.x); for(j = 0; j < w; j++) { ptr[0] = rgbtmp[0] >> 16; ptr[1] = rgbtmp[1] >> 16; ptr[2] = rgbtmp[2] >> 16; rgbtmp[0] += rgbx[0]; rgbtmp[1] += rgbx[1]; rgbtmp[2] += rgbx[2]; ptr += 3; } rgbx[0] += rgby[0]; rgbx[1] += rgby[1]; rgbx[2] += rgby[2]; } inline_draw_crosshair (buf, (priv->spa.width * priv->currval / 0xffff) - x + priv->spa.x - 4, (priv->spa.height * priv->currsat / 0xffff) - y + priv->spa.y - 4, w, h); gdk_draw_rgb_image (widget->parent->window, widget->style->fg_gc[0], x, y, w, h, GDK_RGB_DITHER_NONE, buf, w * 3); g_free(buf); }
int dt_view_manager_switch (dt_view_manager_t *vm, int k) { // Before switching views, restore accelerators if disabled if(!darktable.control->key_accelerators_on) dt_control_key_accelerators_on(darktable.control); // destroy old module list int error = 0; dt_view_t *v = vm->view + vm->current_view; /* Special case when entering nothing (just before leaving dt) */ if ( k==DT_MODE_NONE ) { /* leave the current view*/ if(vm->current_view >= 0 && v->leave) v->leave(v); /* iterator plugins and cleanup plugins in current view */ GList *plugins = g_list_last(darktable.lib->plugins); while (plugins) { dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data); if (!plugin->views) fprintf(stderr,"module %s doesnt have views flags\n",plugin->name()); /* does this module belong to current view ?*/ if (plugin->views() & v->view(v) ) { plugin->gui_cleanup(plugin); dt_accel_disconnect_list(plugin->accel_closures); plugin->accel_closures = NULL; } /* get next plugin */ plugins = g_list_previous(plugins); } /* remove all widets in all containers */ for(int l=0; l<DT_UI_CONTAINER_SIZE; l++) dt_ui_container_clear(darktable.gui->ui, l); vm->current_view = -1 ; return 0 ; } int newv = vm->current_view; if (k < vm->num_views) newv = k; dt_view_t *nv = vm->view + newv; if (nv->try_enter) error = nv->try_enter(nv); if (!error) { GList *plugins; /* cleanup current view before initialization of new */ if (vm->current_view >=0) { /* leave current view */ if(v->leave) v->leave(v); dt_accel_disconnect_list(v->accel_closures); v->accel_closures = NULL; /* iterator plugins and cleanup plugins in current view */ plugins = g_list_last(darktable.lib->plugins); while (plugins) { dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data); if (!plugin->views) fprintf(stderr,"module %s doesnt have views flags\n",plugin->name()); /* does this module belong to current view ?*/ if (plugin->views() & v->view(v) ) { plugin->gui_cleanup(plugin); dt_accel_disconnect_list(plugin->accel_closures); plugin->accel_closures = NULL; } /* get next plugin */ plugins = g_list_previous(plugins); } /* remove all widets in all containers */ for(int l=0; l<DT_UI_CONTAINER_SIZE; l++) dt_ui_container_clear(darktable.gui->ui, l); } /* change current view to the new view */ vm->current_view = newv; /* restore visible stat of panels for the new view */ dt_ui_restore_panels(darktable.gui->ui); /* lets add plugins related to new view into panels */ plugins = g_list_last(darktable.lib->plugins); while (plugins) { dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data); if( plugin->views() & nv->view(v) ) { /* module should be in this view, lets initialize */ plugin->gui_init(plugin); /* try get the module expander */ GtkWidget *w = NULL; w = dt_lib_gui_get_expander(plugin); if(plugin->connect_key_accels) plugin->connect_key_accels(plugin); dt_lib_connect_common_accels(plugin); /* if we dont got an expander lets add the widget */ if (!w) w = plugin->widget; /* add module to it's container */ dt_ui_container_add_widget(darktable.gui->ui, plugin->container(), w); } /* lets get next plugin */ plugins = g_list_previous(plugins); } /* hide/show modules as last config */ plugins = g_list_last(darktable.lib->plugins); while (plugins) { dt_lib_module_t *plugin = (dt_lib_module_t *)(plugins->data); if(plugin->views() & nv->view(v)) { /* set expanded if last mode was that */ char var[1024]; gboolean expanded = FALSE; gboolean visible = dt_lib_is_visible(plugin); if (plugin->expandable()) { snprintf(var, 1024, "plugins/lighttable/%s/expanded", plugin->plugin_name); expanded = dt_conf_get_bool(var); /* show expander if visible */ if(visible) { gtk_widget_show_all(GTK_WIDGET(plugin->expander)); // gtk_widget_show_all(plugin->widget); } else { gtk_widget_hide(GTK_WIDGET(plugin->expander)); // gtk_widget_hide_all(plugin->widget); } dt_lib_gui_set_expanded(plugin, expanded); } else { /* show/hide plugin widget depending on expanded flag or if plugin not is expandeable() */ if(visible) gtk_widget_show_all(plugin->widget); else gtk_widget_hide_all(plugin->widget); } } /* lets get next plugin */ plugins = g_list_previous(plugins); } /* enter view. crucially, do this before initing the plugins below, as e.g. modulegroups requires the dr stuff to be inited. */ if(newv >= 0 && nv->enter) nv->enter(nv); if(newv >= 0 && nv->connect_key_accels) nv->connect_key_accels(nv); /* raise view changed signal */ dt_control_signal_raise(darktable.signals, DT_SIGNAL_VIEWMANAGER_VIEW_CHANGED); /* add endmarkers to left and right center containers */ GtkWidget *endmarker = gtk_drawing_area_new(); dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_LEFT_CENTER, endmarker); g_signal_connect (G_OBJECT (endmarker), "expose-event", G_CALLBACK (dt_control_expose_endmarker), 0); gtk_widget_set_size_request(endmarker, -1, 50); gtk_widget_show(endmarker); endmarker = gtk_drawing_area_new(); dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, endmarker); g_signal_connect (G_OBJECT (endmarker), "expose-event", G_CALLBACK (dt_control_expose_endmarker), (gpointer)1); gtk_widget_set_size_request(endmarker, -1, 50); gtk_widget_show(endmarker); } return error; }