void cb_about_credits(GtkButton *button, gpointer user_data) { gtk_widget_show(GTK_WIDGET(dlg_credits)); }
static void gimp_curves_tool_dialog (GimpImageMapTool *im_tool) { GimpCurvesTool *tool = GIMP_CURVES_TOOL (im_tool); GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (im_tool); GimpCurvesConfig *config = GIMP_CURVES_CONFIG (im_tool->config); GtkListStore *store; GtkWidget *main_vbox; GtkWidget *frame_vbox; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *hbox2; GtkWidget *label; GtkWidget *main_frame; GtkWidget *frame; GtkWidget *table; GtkWidget *button; GtkWidget *bar; GtkWidget *combo; g_signal_connect (im_tool->settings_box, "file-dialog-setup", G_CALLBACK (gimp_curves_tool_export_setup), im_tool); main_vbox = gimp_image_map_tool_dialog_get_vbox (im_tool); /* The combo box for selecting channels */ main_frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (main_vbox), main_frame, TRUE, TRUE, 0); gtk_widget_show (main_frame); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_frame_set_label_widget (GTK_FRAME (main_frame), hbox); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Cha_nnel:")); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, -1); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); store = gimp_enum_store_new_with_range (GIMP_TYPE_HISTOGRAM_CHANNEL, GIMP_HISTOGRAM_VALUE, GIMP_HISTOGRAM_ALPHA); tool->channel_menu = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store)); g_object_unref (store); gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu), config->channel); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (tool->channel_menu), "gimp-channel"); gtk_box_pack_start (GTK_BOX (hbox), tool->channel_menu, FALSE, FALSE, 0); gtk_widget_show (tool->channel_menu); g_signal_connect (tool->channel_menu, "changed", G_CALLBACK (curves_channel_callback), tool); gtk_label_set_mnemonic_widget (GTK_LABEL (label), tool->channel_menu); button = gtk_button_new_with_mnemonic (_("R_eset Channel")); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (curves_channel_reset_callback), tool); /* The histogram scale radio buttons */ hbox2 = gimp_prop_enum_icon_box_new (G_OBJECT (tool_options), "histogram-scale", "gimp-histogram", 0, 0); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_widget_show (hbox2); frame_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4); gtk_container_add (GTK_CONTAINER (main_frame), frame_vbox); gtk_widget_show (frame_vbox); /* The table for the color bars and the graph */ table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (frame_vbox), table, TRUE, TRUE, 0); /* The left color bar */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_table_attach (GTK_TABLE (table), vbox, 0, 1, 0, 1, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (vbox); 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, RADIUS); gtk_widget_show (frame); tool->yrange = gimp_color_bar_new (GTK_ORIENTATION_VERTICAL); gtk_widget_set_size_request (tool->yrange, BAR_SIZE, -1); gtk_container_add (GTK_CONTAINER (frame), tool->yrange); gtk_widget_show (tool->yrange); /* The curves graph */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_table_attach (GTK_TABLE (table), frame, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (frame); tool->graph = gimp_curve_view_new (); gimp_curve_view_set_range_x (GIMP_CURVE_VIEW (tool->graph), 0, 255); gimp_curve_view_set_range_y (GIMP_CURVE_VIEW (tool->graph), 0, 255); gtk_widget_set_size_request (tool->graph, GRAPH_SIZE + RADIUS * 2, GRAPH_SIZE + RADIUS * 2); g_object_set (tool->graph, "border-width", RADIUS, "subdivisions", 1, NULL); gtk_container_add (GTK_CONTAINER (frame), tool->graph); gtk_widget_show (tool->graph); gimp_histogram_options_connect_view (GIMP_HISTOGRAM_OPTIONS (tool_options), GIMP_HISTOGRAM_VIEW (tool->graph)); /* The bottom color bar */ hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_table_attach (GTK_TABLE (table), hbox2, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (hbox2); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX (hbox2), frame, TRUE, TRUE, RADIUS); gtk_widget_show (frame); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); tool->xrange = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL); gtk_widget_set_size_request (tool->xrange, -1, BAR_SIZE / 2); gtk_box_pack_start (GTK_BOX (vbox), tool->xrange, TRUE, TRUE, 0); gtk_widget_show (tool->xrange); bar = gimp_color_bar_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (vbox), bar, TRUE, TRUE, 0); gtk_widget_show (bar); gtk_widget_show (table); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_end (GTK_BOX (frame_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new_with_mnemonic (_("Curve _type:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); tool->curve_type = combo = gimp_enum_combo_box_new (GIMP_TYPE_CURVE_TYPE); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-curve"); gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), 0, G_CALLBACK (curves_curve_type_callback), tool); gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gimp_curves_tool_update_channel (tool); }
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); }
GtkWidget * empathy_preferences_show (GtkWindow *parent) { static EmpathyPreferences *preferences; GladeXML *glade; gchar *filename; if (preferences) { gtk_window_present (GTK_WINDOW (preferences->dialog)); return preferences->dialog; } preferences = g_new0 (EmpathyPreferences, 1); filename = empathy_file_lookup ("empathy-preferences.glade", "src"); glade = empathy_glade_get_file (filename, "preferences_dialog", NULL, "preferences_dialog", &preferences->dialog, "notebook", &preferences->notebook, "checkbutton_show_avatars", &preferences->checkbutton_show_avatars, "checkbutton_compact_contact_list", &preferences->checkbutton_compact_contact_list, "checkbutton_show_smileys", &preferences->checkbutton_show_smileys, "combobox_chat_theme", &preferences->combobox_chat_theme, "checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows, "checkbutton_autoconnect", &preferences->checkbutton_autoconnect, "radiobutton_contact_list_sort_by_name", &preferences->radiobutton_contact_list_sort_by_name, "radiobutton_contact_list_sort_by_state", &preferences->radiobutton_contact_list_sort_by_state, "checkbutton_sounds_enabled", &preferences->checkbutton_sounds_enabled, "checkbutton_sounds_disabled_away", &preferences->checkbutton_sounds_disabled_away, "treeview_sounds", &preferences->treeview_sounds, "treeview_spell_checker", &preferences->treeview_spell_checker, NULL); g_free (filename); empathy_glade_connect (glade, preferences, "preferences_dialog", "destroy", preferences_destroy_cb, "preferences_dialog", "response", preferences_response_cb, NULL); g_object_unref (glade); g_object_add_weak_pointer (G_OBJECT (preferences->dialog), (gpointer) &preferences); preferences_themes_setup (preferences); preferences_setup_widgets (preferences); preferences_languages_setup (preferences); preferences_languages_add (preferences); preferences_languages_load (preferences); preferences_sound_setup (preferences); preferences_sound_load (preferences); if (empathy_spell_supported ()) { GtkWidget *page; page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (preferences->notebook), 2); gtk_widget_show (page); } if (parent) { gtk_window_set_transient_for (GTK_WINDOW (preferences->dialog), GTK_WINDOW (parent)); } gtk_widget_show (preferences->dialog); return preferences->dialog; }
GtkWidget * x264_gtk_window_create (GtkWidget *parent) { GtkWidget *win_x264_gtk; GtkWidget *notebook; GtkWidget *page; GtkWidget *button; GtkWidget *label; X264_Gui_Config *gconfig; X264_Gtk *x264_gtk; gint result; GtkDialogFlags flags = 0; gconfig = (X264_Gui_Config *)g_malloc (sizeof (X264_Gui_Config)); if (!gconfig) return NULL; x264_gtk = x264_gtk_load (); if (parent) flags = GTK_DIALOG_MODAL |GTK_DIALOG_DESTROY_WITH_PARENT; win_x264_gtk = gtk_dialog_new_with_buttons (_("X264 Configuration"), GTK_WINDOW (parent), flags, NULL); button = gtk_button_new_with_label (_("Default")); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (win_x264_gtk)->action_area), button, FALSE, TRUE, 6); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (_default_load), gconfig); gtk_widget_show (button); gtk_dialog_add_buttons (GTK_DIALOG (win_x264_gtk), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_object_set_data (G_OBJECT (win_x264_gtk), "x264-gui-config", gconfig); g_object_set_data (G_OBJECT (win_x264_gtk), "x264-config", x264_gtk); gtk_window_set_resizable (GTK_WINDOW (win_x264_gtk), FALSE); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (win_x264_gtk)->vbox), notebook); gtk_widget_show (notebook); label = gtk_label_new (_("Bitrate")); gtk_widget_show (label); page = _bitrate_page (gconfig); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); gtk_widget_show (page); label = gtk_label_new (_("Rate Control")); gtk_widget_show (label); page = _rate_control_page (gconfig); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); gtk_widget_show (page); label = gtk_label_new (_("MB & Frames")); gtk_widget_show (label); page = _mb_page (gconfig); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); gtk_widget_show (page); label = gtk_label_new (_("More...")); gtk_widget_show (label); page = _more_page (gconfig); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); gtk_widget_show (page); label = gtk_label_new (_("Quantization matrices")); gtk_widget_show (label); page = _cqm_page (gconfig); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, label); gtk_widget_show (page); _current_set (gconfig, x264_gtk); result = gtk_dialog_run (GTK_DIALOG (win_x264_gtk)); _dialog_run (GTK_DIALOG (win_x264_gtk), result, gconfig, x264_gtk); return win_x264_gtk; }
bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { m_miniTitle = 0; if (style & wxCAPTION) m_miniTitle = 16; if (style & wxRESIZE_BORDER) m_miniEdge = 4; else m_miniEdge = 3; m_isDragging = false; m_oldX = -1; m_oldY = -1; m_diffX = 0; m_diffY = 0; // don't allow sizing smaller than decorations int minWidth = 2 * m_miniEdge; int minHeight = 2 * m_miniEdge + m_miniTitle; if (m_minWidth < minWidth) m_minWidth = minWidth; if (m_minHeight < minHeight) m_minHeight = minHeight; wxFrame::Create( parent, id, title, pos, size, style, name ); // Use a GtkEventBox for the title and borders. Using m_widget for this // almost works, except that setting the resize cursor has no effect. GtkWidget* eventbox = gtk_event_box_new(); gtk_widget_add_events(eventbox, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); gtk_widget_show(eventbox); #ifdef __WXGTK3__ g_object_ref(m_mainWidget); gtk_container_remove(GTK_CONTAINER(m_widget), m_mainWidget); gtk_container_add(GTK_CONTAINER(eventbox), m_mainWidget); g_object_unref(m_mainWidget); gtk_widget_set_margin_start(m_mainWidget, m_miniEdge); gtk_widget_set_margin_end(m_mainWidget, m_miniEdge); gtk_widget_set_margin_top(m_mainWidget, m_miniTitle + m_miniEdge); gtk_widget_set_margin_bottom(m_mainWidget, m_miniEdge); #else // Use a GtkAlignment to position m_mainWidget inside the decorations GtkWidget* alignment = gtk_alignment_new(0, 0, 1, 1); gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), m_miniTitle + m_miniEdge, m_miniEdge, m_miniEdge, m_miniEdge); gtk_widget_show(alignment); // The GtkEventBox and GtkAlignment go between m_widget and m_mainWidget gtk_widget_reparent(m_mainWidget, alignment); gtk_container_add(GTK_CONTAINER(eventbox), alignment); #endif gtk_container_add(GTK_CONTAINER(m_widget), eventbox); m_gdkDecor = 0; gtk_window_set_decorated(GTK_WINDOW(m_widget), false); m_gdkFunc = 0; if (style & wxRESIZE_BORDER) m_gdkFunc = GDK_FUNC_RESIZE; gtk_window_set_default_size(GTK_WINDOW(m_widget), m_width, m_height); memset(&m_decorSize, 0, sizeof(m_decorSize)); m_deferShow = false; if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget))) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); } if (m_miniTitle && (style & wxCLOSE_BOX)) { m_closeButton = wxBitmap((const char*)close_bits, 16, 16); m_closeButton.SetMask(new wxMask(m_closeButton)); } /* these are called when the borders are drawn */ #ifdef __WXGTK3__ g_signal_connect_after(eventbox, "draw", G_CALLBACK(draw), this); #else g_signal_connect_after(eventbox, "expose_event", G_CALLBACK(expose_event), this); #endif /* these are required for dragging the mini frame around */ g_signal_connect (eventbox, "button_press_event", G_CALLBACK (gtk_window_button_press_callback), this); g_signal_connect (eventbox, "button_release_event", G_CALLBACK (gtk_window_button_release_callback), this); g_signal_connect (eventbox, "motion_notify_event", G_CALLBACK (gtk_window_motion_notify_callback), this); g_signal_connect (eventbox, "leave_notify_event", G_CALLBACK (gtk_window_leave_callback), this); return true; }
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; }
int main( int argc, char *argv[] ) { GtkWidget *window = NULL; GtkWidget *vbox; GtkWidget *entry; GtkWidget *label; GtkStatusIcon *tray_icon; GdkPixbuf *main_icon; GtkWidget* array_widget[2]; g_type_init (); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { DEBUG ("Failed to make connection to session bus: %s", error->message); g_error_free (error); exit(1); } proxy = dbus_g_proxy_new_for_name ( connection, "org.opensplash.bot", "/org/opensplash/bot/language/Parser", "org.opensplash.bot.language" ); gtk_init (&argc, &argv); x_grab_key_init(); main_icon = gdk_pixbuf_new_from_xpm_data((const char**)splashbox_xpm); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass (GTK_WINDOW(window), "splashbox-bot-frontend-gtk", "splashbox-bot-frontend-gtk"); //gtk_window_set_modal(GTK_WINDOW(window), TRUE); gtk_widget_set_size_request( window, 400, -1); gtk_window_set_has_frame(GTK_WINDOW(window), FALSE); gtk_window_set_resizable (GTK_WINDOW(window), FALSE); gtk_window_set_position (GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_keep_above(GTK_WINDOW(window), TRUE); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(vbox), entry, TRUE, TRUE, 0); // gtk_entry_set_activates_default (GTK_ENTRY(entry), TRUE); gtk_widget_show(entry); label = gtk_label_new("Hi Master, what can I do for you?"); gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); gtk_widget_show(label); tray_icon = gtk_status_icon_new (); gtk_status_icon_set_from_pixbuf(tray_icon, main_icon); gtk_status_icon_set_tooltip(tray_icon, "Use right Alt key to show/hide the input box."); /* array_widget[0] = window; array_widget[1] = label; */ g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK (entry_activated_cb), label); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_activated_cb), window); gtk_widget_hide (window); g_idle_add(grab_key, (gpointer)window); gtk_main (); return 0; }
static void gimp_color_dialog_init (GimpColorDialog *dialog) { GtkWidget *table; GtkWidget *button; GtkWidget *arrow; gint i; color_dialogs = g_list_prepend (color_dialogs, dialog); gtk_dialog_add_buttons (GTK_DIALOG (dialog), GIMP_STOCK_RESET, RESPONSE_RESET, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog), RESPONSE_RESET, GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1); dialog->selection = gimp_color_selection_new (); gtk_container_set_border_width (GTK_CONTAINER (dialog->selection), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), dialog->selection, TRUE, TRUE, 0); gtk_widget_show (dialog->selection); g_signal_connect (dialog->selection, "color-changed", G_CALLBACK (gimp_color_dialog_color_changed), dialog); /* The color history */ table = gtk_table_new (2, 1 + COLOR_HISTORY_SIZE / 2, TRUE); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4); gtk_box_pack_end (GTK_BOX (GIMP_COLOR_SELECTION (dialog->selection)->right_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); button = gtk_button_new (); gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1); gimp_help_set_help_data (button, _("Add the current color to the color history"), NULL); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_color_history_add_clicked), dialog); arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (button), arrow); gtk_widget_show (arrow); for (i = 0; i < COLOR_HISTORY_SIZE; i++) { GimpRGB history_color; gint row, column; column = i % (COLOR_HISTORY_SIZE / 2); row = i / (COLOR_HISTORY_SIZE / 2); button = gtk_button_new (); gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE); gtk_table_attach_defaults (GTK_TABLE (table), button, column + 1, column + 2, row, row + 1); gtk_widget_show (button); color_history_get (i, &history_color); dialog->history[i] = gimp_color_area_new (&history_color, GIMP_COLOR_AREA_SMALL_CHECKS, GDK_BUTTON2_MASK); gtk_container_add (GTK_CONTAINER (button), dialog->history[i]); gtk_widget_show (dialog->history[i]); g_signal_connect (button, "clicked", G_CALLBACK (gimp_color_history_color_clicked), dialog); g_signal_connect (dialog->history[i], "color-changed", G_CALLBACK (gimp_color_history_color_changed), GINT_TO_POINTER (i)); } }
static void test_folder_switch_and_filters (void) { gboolean passed; char *cwd; char *base_dir; GtkFilePath *cwd_path; GtkFilePath *base_dir_path; GtkWidget *dialog; GtkFileFilter *all_filter; GtkFileFilter *txt_filter; GtkFileChooserDefault *impl; passed = TRUE; cwd = g_get_current_dir (); base_dir = g_build_filename (cwd, "file-chooser-test-dir", NULL); dialog = gtk_file_chooser_dialog_new ("Test", NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); impl = get_impl_from_dialog (dialog); cwd_path = gtk_file_system_filename_to_path (impl->file_system, cwd); base_dir_path = gtk_file_system_filename_to_path (impl->file_system, base_dir); passed = passed && gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir); g_assert (passed); /* All files filter */ all_filter = gtk_file_filter_new (); gtk_file_filter_set_name (all_filter, "All files"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), all_filter); /* *.txt filter */ txt_filter = gtk_file_filter_new (); gtk_file_filter_set_name (all_filter, "*.txt"); gtk_file_filter_add_pattern (txt_filter, "*.txt"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), txt_filter); /* Test filter set */ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), all_filter); passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == all_filter); g_assert (passed); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), txt_filter); passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter); log_test (passed, "test_folder_switch_and_filters(): set and get filter"); g_assert (passed); gtk_widget_show (dialog); /* Test that filter is unchanged when we switch folders */ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), cwd); sleep_in_main_loop (0.5); passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter); g_assert (passed); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), base_dir); sleep_in_main_loop (0.25); g_signal_emit_by_name (impl->browse_path_bar, "path-clicked", (GtkFilePath *) cwd_path, (GtkFilePath *) base_dir_path, FALSE); sleep_in_main_loop (0.25); passed = passed && (gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog)) == txt_filter); log_test (passed, "test_folder_switch_and_filters(): filter after changing folder"); g_assert (passed); /* cleanups */ g_free (cwd); g_free (base_dir); gtk_file_path_free (cwd_path); gtk_file_path_free (base_dir_path); gtk_widget_destroy (dialog); log_test (passed, "test_folder_switch_and_filters(): all filter tests"); }
static GtkWidget *p_create_frame_missing(struct LibravatarPrefsPage *page) { GtkWidget *vbox, *radio[NUM_DEF_BUTTONS], *hbox, *entry; gboolean enable = FALSE; int i, e = 0; gchar *radio_label[] = { _("None"), _("Mystery man"), _("Identicon"), _("MonsterID"), _("Wavatar"), _("Retro"), _("Custom URL") }; gchar *radio_hint[] = { _("A blank image"), _("The unobtrusive low-contrast greyish silhouette"), _("A generated geometric pattern"), _("A generated full-body monster"), _("A generated almost unique face"), _("A generated 8-bit arcade-style pixelated image"), _("Redirect to a user provided URL") }; vbox = gtk_vbox_new(FALSE, 6); for (i = 0; i < NUM_DEF_BUTTONS; ++i) { enable = (libravatarprefs.default_mode == radio_value[i])? TRUE: FALSE; e += enable? 1: 0; radio[i] = gtk_radio_button_new_with_label_from_widget( (i > 0)? GTK_RADIO_BUTTON(radio[i - 1]): NULL, radio_label[i]); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio[i]), enable); if (i == CUSTOM_URL_BUTTON_INDEX) { /* set related entry next to radio button */ entry = gtk_entry_new_with_max_length(MAX_URL_LENGTH); CLAWS_SET_TIP(entry, _("Enter the URL you want to be " "redirected when no user icon is available. " "Leave an empty URL to use the default " "libravatar orange icon.")); gtk_widget_show(entry); gtk_entry_set_text(GTK_ENTRY(entry), libravatarprefs.default_mode_url); hbox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(hbox), radio[i], FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); gtk_widget_set_sensitive(entry, (libravatarprefs.default_mode == DEF_MODE_URL) ? TRUE: FALSE); page->defm_url_text = entry; gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); } else { gtk_box_pack_start(GTK_BOX(vbox), radio[i], FALSE, FALSE, 0); } g_signal_connect(radio[i], "toggled", G_CALLBACK(default_mode_radio_button_cb), (gpointer) &(radio_value[i])); CLAWS_SET_TIP(radio[i], radio_hint[i]); gtk_widget_show(radio[i]); page->defm_radio[i] = radio[i]; } if (e == 0) { /* unknown value, go default */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio[0]), TRUE); libravatarprefs.default_mode = DEF_MODE_NONE; } /* don't waste time with headers that won't be displayed */ prefs_common_get_prefs()->enable_avatars = (libravatarprefs.default_mode == DEF_MODE_NONE) ? AVATARS_ENABLE_BOTH: AVATARS_DISABLE; return vbox; }
static gboolean gdict_applet_draw (GdictApplet *applet) { GdictAppletPrivate *priv = applet->priv; GtkWidget *box; GtkWidget *hbox; gchar *text = NULL; if (priv->entry) text = gtk_editable_get_chars (GTK_EDITABLE (priv->entry), 0, -1); if (priv->box) gtk_widget_destroy (priv->box); switch (priv->orient) { case GTK_ORIENTATION_VERTICAL: box = gtk_vbox_new (FALSE, 0); break; case GTK_ORIENTATION_HORIZONTAL: box = gtk_hbox_new (FALSE, 0); break; default: g_assert_not_reached (); break; } gtk_container_add (GTK_CONTAINER (applet), box); gtk_widget_show (box); /* toggle button */ priv->toggle = gtk_toggle_button_new (); gtk_widget_set_tooltip_text (priv->toggle, _("Click to view the dictionary window")); set_atk_name_description (priv->toggle, _("Toggle dictionary window"), _("Show or hide the definition window")); gtk_button_set_relief (GTK_BUTTON (priv->toggle), GTK_RELIEF_NONE); g_signal_connect (priv->toggle, "toggled", G_CALLBACK (gdict_applet_icon_toggled_cb), applet); g_signal_connect (priv->toggle, "button-press-event", G_CALLBACK (gdict_applet_icon_button_press_event_cb), applet); gtk_box_pack_start (GTK_BOX (box), priv->toggle, FALSE, FALSE, 0); gtk_widget_show (priv->toggle); hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 0); gtk_container_add (GTK_CONTAINER (priv->toggle), hbox); gtk_widget_show (hbox); if (priv->icon) { GdkPixbuf *scaled; priv->image = gtk_image_new (); gtk_image_set_pixel_size (GTK_IMAGE (priv->image), priv->size - 10); scaled = gdk_pixbuf_scale_simple (priv->icon, priv->size - 5, priv->size - 5, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), scaled); g_object_unref (scaled); gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0); gtk_widget_show (priv->image); } else { priv->image = gtk_image_new (); gtk_image_set_pixel_size (GTK_IMAGE (priv->image), priv->size - 10); gtk_image_set_from_stock (GTK_IMAGE (priv->image), GTK_STOCK_MISSING_IMAGE, -1); gtk_box_pack_start (GTK_BOX (hbox), priv->image, FALSE, FALSE, 0); gtk_widget_show (priv->image); } /* entry */ priv->entry = gtk_entry_new (); gtk_widget_set_tooltip_text (priv->entry, _("Type the word you want to look up")); set_atk_name_description (priv->entry, _("Dictionary entry"), _("Look up words in dictionaries")); gtk_editable_set_editable (GTK_EDITABLE (priv->entry), TRUE); gtk_entry_set_width_chars (GTK_ENTRY (priv->entry), 12); g_signal_connect (priv->entry, "activate", G_CALLBACK (gdict_applet_entry_activate_cb), applet); g_signal_connect (priv->entry, "button-press-event", G_CALLBACK (gdict_applet_entry_button_press_event_cb), applet); g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (gdict_applet_entry_key_press_cb), applet); gtk_box_pack_end (GTK_BOX (box), priv->entry, FALSE, FALSE, 0); gtk_widget_show (priv->entry); if (text) { gtk_entry_set_text (GTK_ENTRY (priv->entry), text); g_free (text); } priv->box = box; #if 0 gtk_widget_grab_focus (priv->entry); #endif gtk_widget_show_all (GTK_WIDGET (applet)); return FALSE; }
static void gdict_applet_build_window (GdictApplet *applet) { GdictAppletPrivate *priv = applet->priv; GtkWidget *window; GtkWidget *frame; GtkWidget *vbox; GtkWidget *bbox; GtkWidget *button; if (!priv->entry) { g_warning ("No entry widget defined"); return; } window = gdict_aligned_window_new (priv->toggle); g_signal_connect (window, "key-press-event", G_CALLBACK (window_key_press_event_cb), applet); g_signal_connect (window, "show", G_CALLBACK (window_show_cb), applet); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (window), frame); gtk_widget_show (frame); priv->frame = frame; vbox = gtk_vbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); priv->defbox = gdict_defbox_new (); if (priv->context) gdict_defbox_set_context (GDICT_DEFBOX (priv->defbox), priv->context); gtk_box_pack_start (GTK_BOX (vbox), priv->defbox, TRUE, TRUE, 0); gtk_widget_show (priv->defbox); gtk_widget_set_can_focus (priv->defbox, TRUE); gtk_widget_set_can_default (priv->defbox, TRUE); bbox = gtk_hbutton_box_new (); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); gtk_box_set_spacing (GTK_BOX (bbox), 6); gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_widget_show (bbox); button = gtk_button_new_from_stock (GTK_STOCK_CLEAR); gtk_widget_set_tooltip_text (button, _("Clear the definitions found")); set_atk_name_description (button, _("Clear definition"), _("Clear the text of the definition")); g_signal_connect (button, "clicked", G_CALLBACK (clear_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_PRINT); gtk_widget_set_tooltip_text (button, _("Print the definitions found")); set_atk_name_description (button, _("Print definition"), _("Print the text of the definition")); g_signal_connect (button, "clicked", G_CALLBACK (print_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gtk_button_new_from_stock (GTK_STOCK_SAVE); gtk_widget_set_tooltip_text (button, _("Save the definitions found")); set_atk_name_description (button, _("Save definition"), _("Save the text of the definition to a file")); g_signal_connect (button, "clicked", G_CALLBACK (save_cb), applet); gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gtk_window_set_default (GTK_WINDOW (window), priv->defbox); priv->window = window; priv->is_window_showing = FALSE; }
void about_display() { gtk_widget_show(GTK_WIDGET(dlg_about)); }
bool wxListBox::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxListBox creation failed") ); return false; } m_widget = gtk_scrolled_window_new( NULL, NULL ); g_object_ref(m_widget); if (style & wxLB_ALWAYS_SB) { gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS ); } else { gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); } GTKScrolledWindowSetBorder(m_widget, style); m_treeview = GTK_TREE_VIEW( gtk_tree_view_new( ) ); //wxListBox doesn't have a header :) //NB: If enabled SetFirstItem doesn't work correctly gtk_tree_view_set_headers_visible(m_treeview, FALSE); #if wxUSE_CHECKLISTBOX if(m_hasCheckBoxes) ((wxCheckListBox*)this)->DoCreateCheckList(); #endif // wxUSE_CHECKLISTBOX // Create the data column gtk_tree_view_insert_column_with_attributes(m_treeview, -1, "", gtk_cell_renderer_text_new(), "text", WXLISTBOX_DATACOLUMN, NULL); // Now create+set the model (GtkListStore) - first argument # of columns #if wxUSE_CHECKLISTBOX if(m_hasCheckBoxes) m_liststore = gtk_list_store_new(2, G_TYPE_BOOLEAN, GTK_TYPE_TREE_ENTRY); else #endif m_liststore = gtk_list_store_new(1, GTK_TYPE_TREE_ENTRY); gtk_tree_view_set_model(m_treeview, GTK_TREE_MODEL(m_liststore)); g_object_unref (m_liststore); //free on treeview destruction // Disable the pop-up textctrl that enables searching - note that // the docs specify that even if this disabled (which we are doing) // the user can still have it through the start-interactive-search // key binding...either way we want to provide a searchequal callback // NB: If this is enabled a doubleclick event (activate) gets sent // on a successful search gtk_tree_view_set_search_column(m_treeview, WXLISTBOX_DATACOLUMN); gtk_tree_view_set_search_equal_func(m_treeview, (GtkTreeViewSearchEqualFunc) gtk_listbox_searchequal_callback, this, NULL); gtk_tree_view_set_enable_search(m_treeview, FALSE); GtkSelectionMode mode; // GTK_SELECTION_EXTENDED is a deprecated synonym for GTK_SELECTION_MULTIPLE if ( style & (wxLB_MULTIPLE | wxLB_EXTENDED) ) { mode = GTK_SELECTION_MULTIPLE; } else // no multi-selection flags specified { m_windowStyle |= wxLB_SINGLE; mode = GTK_SELECTION_SINGLE; } GtkTreeSelection* selection = gtk_tree_view_get_selection( m_treeview ); gtk_tree_selection_set_mode( selection, mode ); // Handle sortable stuff if(HasFlag(wxLB_SORT)) { // Setup sorting in ascending (wx) order gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(m_liststore), WXLISTBOX_DATACOLUMN, GTK_SORT_ASCENDING); // Set the sort callback gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(m_liststore), WXLISTBOX_DATACOLUMN, (GtkTreeIterCompareFunc) gtk_listbox_sort_callback, this, //userdata NULL //"destroy notifier" ); } gtk_container_add (GTK_CONTAINER (m_widget), GTK_WIDGET(m_treeview) ); gtk_widget_show( GTK_WIDGET(m_treeview) ); m_focusWidget = GTK_WIDGET(m_treeview); Append(n, choices); // insert initial items // generate dclick events g_signal_connect_after(m_treeview, "row-activated", G_CALLBACK(gtk_listbox_row_activated_callback), this); // for intercepting dclick generation by <ENTER> g_signal_connect (m_treeview, "key_press_event", G_CALLBACK (gtk_listbox_key_press_callback), this); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); // need this too because this is a wxControlWithItems g_signal_connect_after (selection, "changed", G_CALLBACK (gtk_listitem_changed_callback), this); return true; }
GtkWidget * module_dialog_new (Gimp *gimp) { GtkWidget *shell; GtkWidget *vbox; GtkWidget *sw; GtkWidget *view; GtkWidget *image; ModuleDialog *dialog; GtkTreeSelection *sel; GtkTreeIter iter; GtkTreeViewColumn *col; GtkCellRenderer *rend; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); dialog = g_slice_new0 (ModuleDialog); dialog->gimp = gimp; shell = gimp_dialog_new (_("Module Manager"), "gimp-modules", NULL, 0, gimp_standard_help_func, GIMP_HELP_MODULE_DIALOG, GTK_STOCK_REFRESH, RESPONSE_REFRESH, GTK_STOCK_CLOSE, GTK_STOCK_CLOSE, NULL); gtk_dialog_set_alternative_button_order (GTK_DIALOG (shell), GTK_RESPONSE_CLOSE, RESPONSE_REFRESH, -1); g_signal_connect (shell, "response", G_CALLBACK (dialog_response), dialog); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (shell))), vbox, TRUE, TRUE, 0); gtk_widget_show (vbox); dialog->hint = gimp_hint_box_new (_("You will have to restart GIMP " "for the changes to take effect.")); gtk_box_pack_start (GTK_BOX (vbox), dialog->hint, FALSE, FALSE, 0); if (gimp->write_modulerc) gtk_widget_show (dialog->hint); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_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); gtk_widget_set_size_request (sw, 124, 100); gtk_widget_show (sw); dialog->list = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_BOOLEAN, GIMP_TYPE_MODULE); view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list)); g_object_unref (dialog->list); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE); g_list_foreach (gimp->module_db->modules, make_list_item, dialog); rend = gtk_cell_renderer_toggle_new (); g_signal_connect (rend, "toggled", G_CALLBACK (dialog_enabled_toggled), dialog); col = gtk_tree_view_column_new (); gtk_tree_view_column_pack_start (col, rend, FALSE); gtk_tree_view_column_add_attribute (col, rend, "active", COLUMN_ENABLED); gtk_tree_view_append_column (GTK_TREE_VIEW (view), col); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view), 1, _("Module"), gtk_cell_renderer_text_new (), "text", COLUMN_NAME, NULL); gtk_container_add (GTK_CONTAINER (sw), view); gtk_widget_show (view); dialog->table = gtk_table_new (2, N_INFOS, FALSE); gtk_table_set_col_spacings (GTK_TABLE (dialog->table), 6); gtk_box_pack_start (GTK_BOX (vbox), dialog->table, FALSE, FALSE, 0); gtk_widget_show (dialog->table); dialog->error_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_box_pack_start (GTK_BOX (vbox), dialog->error_box, FALSE, FALSE, 0); image = gtk_image_new_from_stock (GIMP_STOCK_WARNING, GTK_ICON_SIZE_BUTTON); gtk_box_pack_start (GTK_BOX (dialog->error_box), image, FALSE, FALSE, 0); gtk_widget_show (image); dialog->error_label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (dialog->error_label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (dialog->error_box), dialog->error_label, TRUE, TRUE, 0); gtk_widget_show (dialog->error_label); dialog_info_init (dialog, dialog->table); dialog_info_update (gimp->module_db, dialog->selected, dialog); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (view)); g_signal_connect (sel, "changed", G_CALLBACK (dialog_select_callback), dialog); if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->list), &iter)) gtk_tree_selection_select_iter (sel, &iter); /* hook the GimpModuleDB signals so we can refresh the display * appropriately. */ g_signal_connect (gimp->module_db, "add", G_CALLBACK (dialog_info_add), dialog); g_signal_connect (gimp->module_db, "remove", G_CALLBACK (dialog_info_remove), dialog); g_signal_connect (gimp->module_db, "module-modified", G_CALLBACK (dialog_info_update), dialog); g_signal_connect (shell, "destroy", G_CALLBACK (dialog_destroy_callback), dialog); return shell; }
struct master *add_master_dialog (struct master *m) { GtkWidget *window; GtkWidget *main_vbox; GtkWidget *table; GtkWidget *option_menu; GtkWidget *hbox; GtkWidget *label; GtkWidget *button; GtkWidget *hseparator; char *typestr; enum master_query_type i; struct master *master_to_edit; char *windowtitle; master_name_result = NULL; master_addr_result = NULL; current_master_query_type = MASTER_NATIVE; master_to_edit = NULL; master_to_add = NULL; for (i=MASTER_NATIVE;i<MASTER_NUM_QUERY_TYPES;i++) master_query_type_radios[i]=NULL; master_to_edit = m; if (master_to_edit) { current_master_query_type = master_to_edit->master_type; master_type = master_to_edit->type; } else { // Get last game type added (stored in master_okbutton_callback) typestr = config_get_string ("/" CONFIG_FILE "/Add Master/game"); if (typestr) { master_type = id2type (typestr); g_free (typestr); } else { master_type = QW_SERVER; } } if (master_to_edit) { windowtitle=_("Rename Master"); } else { windowtitle=_("Add Master"); } window = dialog_create_modal_transient_window(windowtitle, TRUE, FALSE, NULL); main_vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), main_vbox); table = gtk_table_new (2, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_container_set_border_width (GTK_CONTAINER (table), 16); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); /* Master Name (Description) */ label = gtk_label_new (_("Master Name")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); hbox = gtk_hbox_new (FALSE, 4); gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 0, 1); master_name_combo = gtk_combo_new (); gtk_widget_set_usize (master_name_combo, 200, -1); gtk_box_pack_start (GTK_BOX (hbox), master_name_combo, TRUE, TRUE, 0); gtk_entry_set_max_length (GTK_ENTRY (GTK_COMBO (master_name_combo)->entry), 256); gtk_combo_set_case_sensitive (GTK_COMBO (master_name_combo), TRUE); gtk_combo_set_use_arrows_always (GTK_COMBO (master_name_combo), TRUE); gtk_combo_disable_activate (GTK_COMBO (master_name_combo)); gtk_signal_connect( GTK_OBJECT (GTK_COMBO (master_name_combo)->entry), "activate", GTK_SIGNAL_FUNC (master_okbutton_callback), GTK_OBJECT (window)); GTK_WIDGET_SET_FLAGS (GTK_COMBO (master_name_combo)->entry, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (GTK_COMBO (master_name_combo)->button, GTK_CAN_FOCUS); gtk_widget_grab_focus (GTK_COMBO (master_name_combo)->entry); gtk_widget_show (master_name_combo); if (master_history_name->items) combo_set_vals (master_name_combo, master_history_name->items, ""); if (master_to_edit) { gtk_entry_set_text(GTK_ENTRY (GTK_COMBO (master_name_combo)->entry), master_to_edit->name); } /* Master Type Option Menu */ option_menu = create_server_type_menu (master_type, create_server_type_menu_filter_configured, GTK_SIGNAL_FUNC(select_master_type_callback)); gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0); if (master_to_edit) { gtk_widget_set_state (option_menu, GTK_STATE_NORMAL); gtk_widget_set_sensitive (GTK_WIDGET(option_menu),FALSE); } gtk_widget_show (option_menu); gtk_widget_show (hbox); /* Master Address */ label = gtk_label_new (_("Master Address")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); master_addr_combo = gtk_combo_new (); gtk_table_attach_defaults (GTK_TABLE (table), master_addr_combo, 1, 2, 1, 2); gtk_entry_set_max_length (GTK_ENTRY (GTK_COMBO (master_addr_combo)->entry), 4096); gtk_combo_set_case_sensitive (GTK_COMBO (master_addr_combo), TRUE); gtk_combo_set_use_arrows_always (GTK_COMBO (master_addr_combo), TRUE); gtk_combo_disable_activate (GTK_COMBO (master_addr_combo)); gtk_signal_connect ( GTK_OBJECT (GTK_COMBO (master_addr_combo)->entry), "activate", GTK_SIGNAL_FUNC (master_okbutton_callback), GTK_OBJECT (window)); gtk_signal_connect ( GTK_OBJECT (GTK_COMBO (master_addr_combo)->list), "selection-changed", GTK_SIGNAL_FUNC (master_address_from_history_selected_callback),NULL); GTK_WIDGET_SET_FLAGS (GTK_COMBO (master_addr_combo)->entry, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS (GTK_COMBO (master_addr_combo)->button, GTK_CAN_FOCUS); // gtk_widget_grab_focus (GTK_COMBO (master_addr_combo)->entry); gtk_widget_show (master_addr_combo); if (master_history_addr->items) combo_set_vals (master_addr_combo, master_history_addr->items, ""); if (master_to_edit) { char* url = master_to_url(master_to_edit); gtk_entry_set_text(GTK_ENTRY (GTK_COMBO (master_addr_combo)->entry), url); gtk_widget_set_state (master_addr_combo, GTK_STATE_NORMAL); gtk_widget_set_sensitive (GTK_WIDGET(master_addr_combo),FALSE); g_free(url); } gtk_widget_show (table); /* query type */ hbox = gtk_hbox_new (TRUE, 8); for (i=MASTER_NATIVE;i<MASTER_NUM_QUERY_TYPES;i++) { master_query_type_radios[i] = gtk_radio_button_new_with_label_from_widget( i==MASTER_NATIVE?NULL:GTK_RADIO_BUTTON(master_query_type_radios[MASTER_NATIVE]), _(master_designation[i])); if (master_to_edit) { gtk_widget_set_sensitive (GTK_WIDGET(master_query_type_radios[i]),FALSE); } gtk_signal_connect(GTK_OBJECT (master_query_type_radios[i]), "toggled", GTK_SIGNAL_FUNC (master_type_radio_callback), (gpointer)i); gtk_widget_show (master_query_type_radios[i]); gtk_box_pack_start (GTK_BOX (hbox),master_query_type_radios[i], FALSE, FALSE, 0); } if (master_to_edit) { master_activate_radio_for_type(current_master_query_type); } else if (!games[master_type].default_master_port && current_master_query_type == MASTER_NATIVE) { gtk_widget_set_state (master_query_type_radios[MASTER_NATIVE], GTK_STATE_NORMAL); gtk_widget_set_sensitive (GTK_WIDGET(master_query_type_radios[MASTER_NATIVE]),FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(master_query_type_radios[MASTER_GAMESPY]),TRUE); } gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); /* Separator */ hseparator = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (main_vbox), hseparator, FALSE, FALSE, 0); gtk_widget_show (hseparator); /* Buttons */ hbox = gtk_hbox_new (FALSE, 8); gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); /* Cancel Button */ button = gtk_button_new_with_label (_("Cancel")); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_set_usize (button, 80, -1); gtk_signal_connect_object (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_show (button); /* OK Button */ button = gtk_button_new_with_label ("OK"); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_set_usize (button, 80, -1); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC(master_okbutton_callback), window); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); gtk_widget_grab_default (button); gtk_widget_show (button); gtk_widget_show (hbox); gtk_widget_show (main_vbox); gtk_widget_show (window); gtk_main (); unregister_window (window); return master_to_add; }
/** * create_directory_config_window(): Create the Directory Configuration Window. * @return Directory Configuration Window. */ GtkWidget* create_directory_config_window(void) { GdkPixbuf *directory_config_window_icon_pixbuf; GtkWidget *vbox_dc; GtkWidget *frame_direntry = NULL, *label_frame_direntry = NULL, *table_frame_direntry = NULL; GtkWidget *label_direntry = NULL, *entry_direntry = NULL, *button_direntry = NULL; GtkWidget *hbutton_box_dc_buttonRow; GtkWidget *button_dc_Cancel, *button_dc_Apply, *button_dc_Save; char tmp[64]; int dir = 0; if (directory_config_window) { // Directory Configuration window is already created. Set focus. gtk_widget_grab_focus(directory_config_window); return NULL; } accel_group = gtk_accel_group_new(); // Create the Directory Configuration window. CREATE_GTK_WINDOW(directory_config_window, "directory_config_window", "Configure Directories", directory_config_window_icon_pixbuf, "Gens2.ico"); // Callbacks for if the window is closed. g_signal_connect((gpointer)directory_config_window, "delete_event", G_CALLBACK(on_directory_config_window_close), NULL); g_signal_connect((gpointer)directory_config_window, "destroy_event", G_CALLBACK(on_directory_config_window_close), NULL); // Create the main VBox. vbox_dc = gtk_vbox_new(FALSE, 10); gtk_widget_set_name(vbox_dc, "vbox_dc"); gtk_widget_show(vbox_dc); gtk_container_add(GTK_CONTAINER(directory_config_window), vbox_dc); GLADE_HOOKUP_OBJECT(directory_config_window, vbox_dc, "vbox_dc"); // Create the directory entry frame. frame_direntry = gtk_frame_new(NULL); gtk_widget_set_name(frame_direntry, "frame_direntry"); gtk_container_set_border_width(GTK_CONTAINER(frame_direntry), 4); gtk_frame_set_shadow_type(GTK_FRAME(frame_direntry), GTK_SHADOW_ETCHED_IN); gtk_widget_show(frame_direntry); gtk_box_pack_start(GTK_BOX(vbox_dc), frame_direntry, TRUE, TRUE, 0); GLADE_HOOKUP_OBJECT(directory_config_window, frame_direntry, "frame_direntry"); // Add the frame label. label_frame_direntry = gtk_label_new("<b><i>Configure Directories</i></b>"); gtk_widget_set_name(label_frame_direntry, "label_frame_direntry"); gtk_label_set_use_markup(GTK_LABEL(label_frame_direntry), TRUE); gtk_widget_show(label_frame_direntry); gtk_frame_set_label_widget(GTK_FRAME(frame_direntry), label_frame_direntry); GLADE_HOOKUP_OBJECT(directory_config_window, label_frame_direntry, "label_frame_direntry"); // Add the frame table. table_frame_direntry = gtk_table_new(1, 3, FALSE); gtk_widget_set_name(table_frame_direntry, "table_frame_direntry"); gtk_container_set_border_width(GTK_CONTAINER(table_frame_direntry), 8); gtk_table_set_row_spacings(GTK_TABLE(table_frame_direntry), 4); gtk_table_set_col_spacings(GTK_TABLE(table_frame_direntry), 4); gtk_widget_show(table_frame_direntry); gtk_container_add(GTK_CONTAINER(frame_direntry), table_frame_direntry); GLADE_HOOKUP_OBJECT(directory_config_window, table_frame_direntry, "table_frame_direntry"); // Create all directory entries. while (DirEntries[dir].title) { // Check if the table needs to be resized. if (dir > 0) gtk_table_resize(GTK_TABLE(table_frame_direntry), dir + 1, 3); // Create the label for this file. sprintf(tmp, "label_%s", DirEntries[dir].tag); label_direntry = gtk_label_new(DirEntries[dir].title); gtk_widget_set_name(label_direntry, tmp); gtk_widget_set_size_request(label_direntry, 100, -1); gtk_misc_set_alignment(GTK_MISC(label_direntry), 0, 0.5); gtk_widget_show(label_direntry); gtk_table_attach(GTK_TABLE(table_frame_direntry), label_direntry, 0, 1, dir, dir + 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); GLADE_HOOKUP_OBJECT(directory_config_window, label_direntry, tmp); // Create the entry for this file. sprintf(tmp, "entry_%s", DirEntries[dir].tag); entry_direntry = gtk_entry_new(); gtk_widget_set_name(entry_direntry, tmp); gtk_entry_set_max_length(GTK_ENTRY(entry_direntry), GENS_PATH_MAX - 1); gtk_entry_set_text(GTK_ENTRY(entry_direntry), DirEntries[dir].entry); gtk_widget_set_size_request(entry_direntry, 250, -1); gtk_widget_show(entry_direntry); gtk_table_attach(GTK_TABLE(table_frame_direntry), entry_direntry, 1, 2, dir, dir + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(0), 0, 0); GLADE_HOOKUP_OBJECT(directory_config_window, entry_direntry, tmp); // Create the button for this file. // TODO: Use an icon? sprintf(tmp, "button_%s", DirEntries[dir].tag); button_direntry = gtk_button_new_with_label("Change..."); gtk_widget_set_name(button_direntry, tmp); gtk_widget_show(button_direntry); gtk_table_attach(GTK_TABLE(table_frame_direntry), button_direntry, 2, 3, dir, dir + 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); g_signal_connect((gpointer)button_direntry, "clicked", G_CALLBACK(on_button_dc_Change_clicked), GINT_TO_POINTER(dir)); GLADE_HOOKUP_OBJECT(directory_config_window, button_direntry, tmp); dir++; } // HButton Box for the row of buttons on the bottom of the window hbutton_box_dc_buttonRow = gtk_hbutton_box_new(); gtk_widget_set_name(hbutton_box_dc_buttonRow, "hbutton_box_dc_buttonRow"); gtk_button_box_set_layout(GTK_BUTTON_BOX(hbutton_box_dc_buttonRow), GTK_BUTTONBOX_END); gtk_widget_show(hbutton_box_dc_buttonRow); gtk_box_pack_start(GTK_BOX(vbox_dc), hbutton_box_dc_buttonRow, FALSE, FALSE, 0); GLADE_HOOKUP_OBJECT(directory_config_window, hbutton_box_dc_buttonRow, "hbutton_box_dc_buttonRow"); // Cancel button_dc_Cancel = gtk_button_new_from_stock("gtk-cancel"); gtk_widget_set_name(button_dc_Cancel, "button_dc_cancel"); gtk_widget_show(button_dc_Cancel); gtk_box_pack_start(GTK_BOX(hbutton_box_dc_buttonRow), button_dc_Cancel, FALSE, FALSE, 0); gtk_widget_add_accelerator(button_dc_Cancel, "activate", accel_group, GDK_Escape, (GdkModifierType)(0), (GtkAccelFlags)(0)); AddButtonCallback_Clicked(button_dc_Cancel, on_button_dc_Cancel_clicked); GLADE_HOOKUP_OBJECT(directory_config_window, button_dc_Cancel, "button_dc_Cancel"); // Apply button_dc_Apply = gtk_button_new_from_stock("gtk-apply"); gtk_widget_set_name(button_dc_Apply, "button_dc_Apply"); gtk_widget_show(button_dc_Apply); gtk_box_pack_start(GTK_BOX(hbutton_box_dc_buttonRow), button_dc_Apply, FALSE, FALSE, 0); gtk_widget_add_accelerator(button_dc_Apply, "activate", accel_group, GDK_Escape, (GdkModifierType)(0), (GtkAccelFlags)(0)); AddButtonCallback_Clicked(button_dc_Apply, on_button_dc_Apply_clicked); GLADE_HOOKUP_OBJECT(directory_config_window, button_dc_Apply, "button_dc_Apply"); // Save button_dc_Save = gtk_button_new_from_stock("gtk-save"); gtk_widget_set_name(button_dc_Save, "button_dc_Save"); gtk_widget_show(button_dc_Save); gtk_box_pack_start(GTK_BOX(hbutton_box_dc_buttonRow), button_dc_Save, FALSE, FALSE, 0); gtk_widget_add_accelerator(button_dc_Save, "activate", accel_group, GDK_Return, (GdkModifierType)(0), (GtkAccelFlags)(0)); gtk_widget_add_accelerator(button_dc_Save, "activate", accel_group, GDK_KP_Enter, (GdkModifierType)(0), (GtkAccelFlags)(0)); AddButtonCallback_Clicked(button_dc_Save, on_button_dc_Save_clicked); GLADE_HOOKUP_OBJECT(directory_config_window, button_dc_Save, "button_dc_Save"); // Add the accel group. gtk_window_add_accel_group(GTK_WINDOW(directory_config_window), accel_group); return directory_config_window; }
static GObject * mud_subwindow_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties) { GtkWidget *term_box; MudWindow *app; GtkWidget *main_window; MudSubwindow *self; GObject *obj; MudSubwindowClass *klass; GObjectClass *parent_class; GtkBuilder *builder; /* Chain up to parent constructor */ klass = MUD_SUBWINDOW_CLASS( g_type_class_peek(MUD_TYPE_SUBWINDOW) ); parent_class = G_OBJECT_CLASS( g_type_class_peek_parent(klass) ); obj = parent_class->constructor(gtype, n_properties, properties); self = MUD_SUBWINDOW(obj); if(!self->priv->parent_view) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing parent view\n"); g_error("Tried to instantiate MudSubwindow without passing parent view"); } if(!self->priv->title) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing title\n"); g_error("Tried to instantiate MudSubwindow without passing title."); } if(!self->priv->identifier) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing identifier\n"); g_error("Tried to instantiate MudSubwindow without passing identifier."); } if(self->priv->width == 0 || self->priv->height == 0) { g_printf("ERROR: Tried to instantiate MudSubwindow without passing valid width/height\n"); g_error("Tried to instantiate MudSubwindow without passing valid width/height."); } self->priv->old_width = self->priv->width; self->priv->old_height = self->priv->height; self->priv->initial_width = self->priv->width; self->priv->initial_height = self->priv->height; /* start glading */ builder = gtk_builder_new_from_resource ("/org/gnome/MUD/main.ui"); self->priv->window = GTK_WIDGET(gtk_builder_get_object(builder, "subwindow")); g_object_unref(builder); gtk_window_set_type_hint(GTK_WINDOW(self->priv->window), GDK_WINDOW_TYPE_HINT_UTILITY); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(self->priv->window), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(self->priv->window), TRUE); g_object_get(self->priv->parent_view, "window", &app, NULL); g_object_get(app, "window", &main_window, NULL); gtk_window_set_transient_for(GTK_WINDOW(self->priv->window), GTK_WINDOW(main_window)); self->priv->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); self->priv->entry = gtk_entry_new(); gtk_widget_hide(self->priv->entry); self->priv->terminal = vte_terminal_new(); self->priv->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->priv->terminal))); term_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); vte_terminal_set_encoding(VTE_TERMINAL(self->priv->terminal), "ISO-8859-1", NULL); /* TODO: This is deprecated; if keeping, at least add error handling? */ /* TODO: set_emulation doesn't exist anymore. We don't really care, but does it affect TTYPE queries? */ /* vte_terminal_set_emulation(VTE_TERMINAL(self->priv->terminal), "xterm"); */ vte_terminal_set_cursor_shape(VTE_TERMINAL(self->priv->terminal), VTE_CURSOR_SHAPE_UNDERLINE); vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(self->priv->terminal), VTE_CURSOR_BLINK_OFF); vte_terminal_set_size(VTE_TERMINAL(self->priv->terminal), self->priv->initial_width, self->priv->initial_height); gtk_box_pack_start(GTK_BOX(term_box), self->priv->terminal, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(term_box), self->priv->scrollbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->priv->vbox), term_box, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(self->priv->vbox), self->priv->entry, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(self->priv->window), self->priv->vbox); gtk_window_set_title(GTK_WINDOW(self->priv->window), self->priv->title); gtk_widget_show(term_box); gtk_widget_show(self->priv->vbox); if(self->priv->scroll) gtk_widget_show(self->priv->scrollbar); gtk_widget_show(self->priv->terminal); gtk_widget_show(self->priv->window); gtk_window_get_size(GTK_WINDOW(self->priv->window), &self->priv->pixel_width, &self->priv->pixel_height); return obj; }
static void save_settings_clicked(GtkWidget *widget, gpointer data) { struct trace_capture *cap = data; struct stat st; GtkWidget *dialog; GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; GString *file; const char *name; gint result; int ret; dialog = gtk_dialog_new_with_buttons("Save Settings", NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); label = gtk_label_new("Settings Name: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); again: result = gtk_dialog_run(GTK_DIALOG(dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: name = gtk_entry_get_text(GTK_ENTRY(entry)); if (!name || is_just_ws(name)) { warning("Must enter a name"); goto again; } /* Make sure home settings exists */ if (create_home_settings() < 0) break; file = get_home_settings_new(); g_string_append_printf(file, "/%s.kss", name); ret = stat(file->str, &st); if (ret >= 0) { ret = trace_dialog(GTK_WINDOW(dialog), TRACE_GUI_ASK, "The setting '%s' already exists.\n" "Are you sure you want to replace it", name); if (ret == GTK_RESPONSE_NO) { g_string_free(file, TRUE); goto again; } } save_settings(cap, file->str); refresh_settings(cap); g_free(cap->info->cap_settings_name); cap->info->cap_settings_name = g_strdup(name); set_settings(cap); g_string_free(file, TRUE); break; case GTK_RESPONSE_REJECT: break; default: break; }; gtk_widget_destroy(dialog); }
static void prefs_summary_column_create(void) { GtkWidget *window; GtkWidget *vbox; GtkWidget *label_hbox; GtkWidget *label; GtkWidget *vbox1; GtkWidget *hbox1; GtkWidget *clist_hbox; GtkWidget *scrolledwin; GtkWidget *stock_clist; GtkWidget *shown_clist; GtkWidget *btn_vbox; GtkWidget *btn_vbox1; GtkWidget *add_btn; GtkWidget *remove_btn; GtkWidget *up_btn; GtkWidget *down_btn; GtkWidget *btn_hbox; GtkWidget *default_btn; GtkWidget *confirm_area; GtkWidget *ok_btn; GtkWidget *cancel_btn; gchar *title[1]; debug_print("Creating summary column setting window...\n"); window = gtk_window_new(GTK_WINDOW_DIALOG); gtk_container_set_border_width(GTK_CONTAINER(window), 8); gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(window), TRUE); gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); gtk_window_set_title(GTK_WINDOW(window), _("Displayed items configuration")); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(prefs_summary_column_delete_event), NULL); gtk_signal_connect(GTK_OBJECT(window), "key_press_event", GTK_SIGNAL_FUNC(prefs_summary_column_key_pressed), NULL); vbox = gtk_vbox_new(FALSE, 6); gtk_widget_show(vbox); gtk_container_add(GTK_CONTAINER(window), vbox); label_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(label_hbox); gtk_box_pack_start(GTK_BOX(vbox), label_hbox, FALSE, FALSE, 4); label = gtk_label_new (_("Select items to be displayed in the summary view. You can modify\n" "the order by using the Up / Down buttons or by dragging the items.")); gtk_widget_show(label); gtk_box_pack_start(GTK_BOX(label_hbox), label, FALSE, FALSE, 4); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); vbox1 = gtk_vbox_new(FALSE, VSPACING); gtk_widget_show(vbox1); gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2); hbox1 = gtk_hbox_new(FALSE, 8); gtk_widget_show(hbox1); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0); clist_hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show(clist_hbox); gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0); scrolledwin = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_usize(scrolledwin, 180, 210); gtk_widget_show(scrolledwin); gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); title[0] = _("Available items"); stock_clist = gtk_clist_new_with_titles(1, title); gtk_widget_show(stock_clist); gtk_container_add(GTK_CONTAINER(scrolledwin), stock_clist); gtk_clist_set_selection_mode(GTK_CLIST(stock_clist), GTK_SELECTION_BROWSE); GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(stock_clist)->column[0].button, GTK_CAN_FOCUS); /* add/remove button */ btn_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(btn_vbox); gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0); btn_vbox1 = gtk_vbox_new(FALSE, 8); gtk_widget_show(btn_vbox1); gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0); add_btn = gtk_button_new_with_label(_(" -> ")); gtk_widget_show(add_btn); gtk_box_pack_start(GTK_BOX(btn_vbox1), add_btn, FALSE, FALSE, 0); remove_btn = gtk_button_new_with_label(_(" <- ")); gtk_widget_show(remove_btn); gtk_box_pack_start(GTK_BOX(btn_vbox1), remove_btn, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(add_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_add), NULL); gtk_signal_connect(GTK_OBJECT(remove_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_remove), NULL); clist_hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show(clist_hbox); gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0); scrolledwin = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_usize(scrolledwin, 180, 210); gtk_widget_show(scrolledwin); gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); title[0] = _("Displayed items"); shown_clist = gtk_clist_new_with_titles(1, title); gtk_widget_show(shown_clist); gtk_container_add(GTK_CONTAINER(scrolledwin), shown_clist); gtk_clist_set_selection_mode(GTK_CLIST(shown_clist), GTK_SELECTION_BROWSE); gtk_clist_set_reorderable(GTK_CLIST(shown_clist), TRUE); gtk_clist_set_use_drag_icons(GTK_CLIST(shown_clist), FALSE); GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(shown_clist)->column[0].button, GTK_CAN_FOCUS); /* up/down button */ btn_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(btn_vbox); gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0); btn_vbox1 = gtk_vbox_new(FALSE, 8); gtk_widget_show(btn_vbox1); gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0); up_btn = gtk_button_new_with_label(_("Up")); gtk_widget_show(up_btn); gtk_box_pack_start(GTK_BOX(btn_vbox1), up_btn, FALSE, FALSE, 0); down_btn = gtk_button_new_with_label(_("Down")); gtk_widget_show(down_btn); gtk_box_pack_start(GTK_BOX(btn_vbox1), down_btn, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(up_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_up), NULL); gtk_signal_connect(GTK_OBJECT(down_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_down), NULL); btn_hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show(btn_hbox); gtk_box_pack_end(GTK_BOX(vbox), btn_hbox, FALSE, FALSE, 0); btn_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(btn_vbox); gtk_box_pack_start(GTK_BOX(btn_hbox), btn_vbox, FALSE, FALSE, 0); default_btn = gtk_button_new_with_label(_(" Use default ")); gtk_widget_show(default_btn); gtk_box_pack_start(GTK_BOX(btn_vbox), default_btn, TRUE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(default_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_set_to_default), NULL); gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"), &cancel_btn, _("Cancel"), NULL, NULL); gtk_widget_show(confirm_area); gtk_box_pack_end(GTK_BOX(btn_hbox), confirm_area, FALSE, FALSE, 0); gtk_widget_grab_default(ok_btn); gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_ok), NULL); gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked", GTK_SIGNAL_FUNC(prefs_summary_column_cancel), NULL); summary_col.window = window; summary_col.stock_clist = stock_clist; summary_col.shown_clist = shown_clist; summary_col.add_btn = add_btn; summary_col.remove_btn = remove_btn; summary_col.up_btn = up_btn; summary_col.down_btn = down_btn; summary_col.ok_btn = ok_btn; summary_col.cancel_btn = cancel_btn; }
/* * Trace Capture Dialog Window * * +--------------------------------------------------------------------+ * | Dialog Window | * | +-------------------------------+-------------------------------+ | * | | Paned Window | +---------------------------+ | | * | | +---------------------------+ | | Scroll window | | | * | | | Hbox | | | +-----------------------+ | | | * | | | Label Plugin Combo | | | | Event Tree | | | | * | | +---------------------------+ | | | | | | | * | | | | | | | | | * | | | | +-----------------------+ | | | * | | | +---------------------------+ | | * | +-------------------------------+-------------------------------+ | * +--------------------------------------------------------------------+ */ static void tracing_dialog(struct shark_info *info, const char *tracing) { struct pevent *pevent; GtkWidget *dialog; GtkWidget *button; GtkWidget *combo; GtkWidget *label; GtkWidget *entry; GtkWidget *frame; GtkWidget *vbox; GtkWidget *scrollwin; GtkWidget *table; GtkWidget *table2; GtkWidget *event_tree; GtkWidget *viewport; GtkWidget *textview; GtkWidget *hbox; GtkTextBuffer *buffer; GtkTextIter start_iter; GtkTextIter end_iter; char **plugins; int nr_plugins; struct trace_capture cap; const gchar *file; const char *command; const char *val; GString *str; gint result; memset(&cap, 0, sizeof(cap)); cap.info = info; plugins = tracecmd_local_plugins(tracing); /* Skip latency plugins */ nr_plugins = trim_plugins(plugins); if (!nr_plugins && plugins) { tracecmd_free_list(plugins); plugins = NULL; } /* Send parse warnings to status display */ trace_dialog_register_alt_warning(vpr_stat); pevent = tracecmd_local_events(tracing); trace_dialog_register_alt_warning(NULL); cap.pevent = pevent; if (!pevent && !nr_plugins) { warning("No events or plugins found"); return; } dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), "Capture"); button = gtk_button_new_with_label("Run"); gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button, GTK_RESPONSE_ACCEPT); gtk_widget_show(button); cap.run_button = button; gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT); cap.main_dialog = dialog; /* --- Top Level Hpaned --- */ table = gtk_table_new(4, 2, FALSE); /* It is possible that no pevents exist. */ if (pevent) { scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_table_attach(GTK_TABLE(table), scrollwin, 0, 1, 1, 2, GTK_FILL, GTK_FILL|GTK_EXPAND, 0, 0); gtk_widget_show(scrollwin); event_tree = trace_create_event_list_view(pevent, NULL, cap.info->cap_all_events, cap.info->cap_systems, cap.info->cap_events); gtk_container_add(GTK_CONTAINER(scrollwin), event_tree); gtk_widget_show(event_tree); cap.event_view = event_tree; } else { /* No events */ label = gtk_label_new("No events enabled on system"); gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_EXPAND|GTK_FILL, 0, 10); gtk_widget_show(label); cap.event_view = NULL; } gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0); gtk_widget_show(table); /*------------------ Frame Settings --------------------------- */ frame = gtk_frame_new("Settings"); gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 0, 1, GTK_FILL, 0, 0, 10); gtk_widget_show(frame); table2 = gtk_table_new(2, 3, FALSE); gtk_container_add(GTK_CONTAINER(frame), table2); gtk_widget_show(table2); gtk_table_set_col_spacings(GTK_TABLE(table2), 5); button = gtk_button_new_with_label("Save Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 0, 1, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (save_settings_clicked), (gpointer)&cap); button = gtk_button_new_with_label("Import Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 1, 2, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (import_settings_clicked), (gpointer)&cap); button = gtk_button_new_with_label("Export Settings"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 2, 3, 0, 1); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (export_settings_clicked), (gpointer)&cap); if (cap.info->cap_settings_name) set_settings(&cap); label = gtk_label_new("Available Settings: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 1, 2); gtk_widget_show(label); combo = trace_create_combo_box(NULL, NULL, create_settings_model, NULL); gtk_table_attach_defaults(GTK_TABLE(table2), combo, 1, 3, 1, 2); cap.settings_combo = combo; g_signal_connect (combo, "changed", G_CALLBACK (settings_changed), (gpointer)&cap); /*------------------ Frame Settings --------------------------- */ frame = gtk_frame_new("Execute"); gtk_table_attach(GTK_TABLE(table), frame, 0, 1, 3, 4, GTK_FILL, 0, 0, 10); gtk_widget_show(frame); table2 = gtk_table_new(3, 3, FALSE); gtk_container_add(GTK_CONTAINER(frame), table2); gtk_widget_show(table2); label = gtk_label_new("Plugin: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 0, 1); gtk_widget_show(label); combo = trace_create_combo_box(NULL, NULL, create_plugin_combo_model, plugins); cap.plugin_combo = combo; gtk_table_attach_defaults(GTK_TABLE(table2), combo, 1, 3, 0, 1); if (cap.info->cap_plugin) set_plugin(&cap); label = gtk_label_new("Command:"); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 1, 2); gtk_widget_show(label); entry = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table2), entry, 1, 3, 1, 2); gtk_widget_show(entry); cap.command_entry = entry; if (cap.info->cap_command) gtk_entry_set_text(GTK_ENTRY(entry), cap.info->cap_command); label = gtk_label_new("Output file: "); gtk_table_attach_defaults(GTK_TABLE(table2), label, 0, 1, 2, 3); gtk_widget_show(label); entry = gtk_entry_new(); gtk_table_attach_defaults(GTK_TABLE(table2), entry, 1, 2, 2, 3); gtk_widget_show(entry); if (cap.info->cap_file) file = cap.info->cap_file; else file = default_output_file; gtk_entry_set_text(GTK_ENTRY(entry), file); cap.file_entry = entry; button = gtk_button_new_with_label("Browse"); gtk_table_attach_defaults(GTK_TABLE(table2), button, 2, 3, 2, 3); gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (file_clicked), (gpointer)&cap); /*------------------ Command Output ------------------ */ vbox = gtk_vbox_new(FALSE, 0); gtk_table_attach_defaults(GTK_TABLE(table), vbox, 1, 2, 0, 4); gtk_widget_show(vbox); gtk_widget_set_size_request(GTK_WIDGET(vbox), 500, 0); label = gtk_label_new("Output Display:"); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); gtk_widget_show(label); scrollwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); gtk_widget_show(scrollwin); viewport = gtk_viewport_new(NULL, NULL); gtk_widget_show(viewport); gtk_container_add(GTK_CONTAINER(scrollwin), viewport); textview = gtk_text_view_new(); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); gtk_container_add(GTK_CONTAINER(viewport), textview); gtk_widget_show(textview); cap.output_text = textview; cap.output_buffer = buffer; /* set the buffer from its previous setting */ if (info->cap_buffer_output) gtk_text_buffer_set_text(buffer, info->cap_buffer_output, strlen(info->cap_buffer_output)); hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); label = gtk_label_new("Max # of characters in output display: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); cap.max_num_entry = entry; if (!info->cap_max_buf_size) info->cap_max_buf_size = DEFAULT_MAX_BUF_SIZE; str = g_string_new(""); g_string_append_printf(str, "%d", info->cap_max_buf_size); gtk_entry_set_text(GTK_ENTRY(entry), str->str); g_string_free(str, TRUE); g_signal_connect (entry, "insert-text", G_CALLBACK (insert_text), (gpointer)&cap); gtk_widget_set_size_request(GTK_WIDGET(dialog), DIALOG_WIDTH, DIALOG_HEIGHT); gtk_widget_show(dialog); cont: result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { execute_button_clicked(&cap); goto cont; } /* Make sure no capture is running */ end_capture(&cap); /* Get the max buffer size */ val = gtk_entry_get_text(GTK_ENTRY(entry)); info->cap_max_buf_size = atoi(val); gtk_text_buffer_get_start_iter(cap.output_buffer, &start_iter); gtk_text_buffer_get_end_iter(cap.output_buffer, &end_iter); g_free(info->cap_buffer_output); info->cap_buffer_output = gtk_text_buffer_get_text(cap.output_buffer, &start_iter, &end_iter, FALSE); /* save the plugin and file to reuse if we come back */ update_plugin(&cap); free(info->cap_file); cap.info->cap_file = strdup(gtk_entry_get_text(GTK_ENTRY(cap.file_entry))); free(info->cap_command); command = gtk_entry_get_text(GTK_ENTRY(cap.command_entry)); if (command && strlen(command) && !is_just_ws(command)) cap.info->cap_command = strdup(command); else cap.info->cap_command = NULL; update_events(&cap); gtk_widget_destroy(dialog); if (pevent) pevent_free(pevent); if (plugins) tracecmd_free_list(plugins); }
/** * gimp_transform_options_gui: * @tool_options: a #GimpToolOptions * * Build the Transform Tool Options. * * Return value: a container holding the transform tool options **/ GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); GtkWidget *hbox; GtkWidget *box; GtkWidget *label; GtkWidget *frame; GtkWidget *combo; GtkWidget *scale; GtkWidget *grid_box; const gchar *constrain_name = NULL; const gchar *constrain_label = NULL; const gchar *constrain_tip = NULL; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Transform:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0); gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0); gtk_widget_show (box); frame = gimp_prop_enum_radio_frame_new (config, "direction", _("Direction"), 0, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the interpolation menu */ combo = gimp_prop_enum_combo_box_new (config, "interpolation", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Interpolation")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the clipping menu */ combo = gimp_prop_enum_combo_box_new (config, "clip", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Clipping")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the preview frame */ scale = gimp_prop_spin_scale_new (config, "preview-opacity", _("Image opacity"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); frame = gimp_prop_expanding_frame_new (config, "show-preview", _("Show image preview"), scale, NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides frame */ frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides type menu */ combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Guides")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_frame_set_label_widget (GTK_FRAME (frame), combo); gtk_widget_show (combo); /* the grid density scale */ scale = gimp_prop_spin_scale_new (config, "grid-size", NULL, 1.8, 8.0, 0); gtk_container_add (GTK_CONTAINER (frame), scale); g_object_bind_property_full (config, "grid-type", scale, "visible", G_BINDING_SYNC_CREATE, gimp_transform_options_sync_grid, NULL, NULL, NULL); if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL) { constrain_name = "constrain-rotate"; constrain_label = _("15 degrees (%s)"); constrain_tip = _("Limit rotation steps to 15 degrees"); } else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL) { constrain_name = "constrain-scale"; constrain_label = _("Keep aspect (%s)"); constrain_tip = _("Keep the original aspect ratio"); } //TODO: check that the selection tools use the gimp_get_*_mask() functions for constrain/etc or change to what they use else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL) { GdkModifierType shift = gimp_get_extend_selection_mask (); GdkModifierType ctrl = gimp_get_constrain_behavior_mask (); struct { GdkModifierType mod; gchar *name; gchar *desc; gchar *tip; } opt_list[] = { { shift, NULL, "Constrain (%s)" }, { shift, "constrain-move", "Move", "Constrain movement to 45 degree angles from center (%s)" }, { shift, "constrain-scale", "Scale", "Maintain aspect ratio when scaling (%s)" }, { shift, "constrain-rotate", "Rotate", "Constrain rotation to 15 degree increments (%s)" }, { shift, "constrain-shear", "Shear", "Shear along edge direction only (%s)" }, { shift, "constrain-perspective", "Perspective", "Constrain perspective handles to move along edges and diagonal (%s)" }, { ctrl, NULL, "From pivot (%s)" }, { ctrl, "frompivot-scale", "Scale", "Scale from pivot point (%s)" }, { ctrl, "frompivot-shear", "Shear", "Shear opposite edge by same amount (%s)" }, { ctrl, "frompivot-perspective", "Perspective", "Maintain position of pivot while changing perspective (%s)" }, { 0, NULL, "Pivot" }, { shift, "cornersnap", "Snap (%s)", "Snap pivot to corners and center (%s)" }, { 0, "fixedpivot", "Lock", "Lock pivot position to canvas" }, }; GtkWidget *button; gchar *label; gint i; frame = NULL; for (i = 0; i < G_N_ELEMENTS (opt_list); i++) { if (!opt_list[i].name && !opt_list[i].desc) { frame = NULL; continue; } label = g_strdup_printf (opt_list[i].desc, gimp_get_mod_string (opt_list[i].mod)); if (opt_list[i].name) { button = gimp_prop_check_button_new (config, opt_list[i].name, label); gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_free (label); label = g_strdup_printf (opt_list[i].tip, gimp_get_mod_string (opt_list[i].mod)); gimp_help_set_help_data (button, label, NULL); } else { frame = gimp_frame_new (label); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), grid_box); gtk_widget_show (grid_box); } g_free (label); } } if (constrain_label) { GtkWidget *button; gchar *label; GdkModifierType constrain_mask; constrain_mask = gimp_get_extend_selection_mask (); label = g_strdup_printf (constrain_label, gimp_get_mod_string (constrain_mask)); button = gimp_prop_check_button_new (config, constrain_name, label); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gimp_help_set_help_data (button, constrain_tip, NULL); g_free (label); } return vbox; }
void odpri_cb(GtkObject *object, gpointer user_data){ gtk_widget_show(fc); }
int DoLoadPortalFileDialog( GtkWidget *parent ){ GtkWidget *dialog, *vbox, *hbox, *button, *entry, *check2d, *check3d; GtkWidget *content_area, *ok_button, *cancel_button, *change_button; gint response_id; int ret; GtkSizeGroup *size_group; GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT; dialog = gtk_dialog_new_with_buttons( _( "Load .prt" ), NULL, flags, NULL ); gtk_window_set_transient_for( GTK_WINDOW( dialog ), GTK_WINDOW( parent ) ); ok_button = gtk_dialog_add_button( GTK_DIALOG( dialog ), _( "OK" ), GTK_RESPONSE_OK ); cancel_button = gtk_dialog_add_button( GTK_DIALOG( dialog ), _( "Cancel" ), GTK_RESPONSE_CANCEL ); content_area = gtk_dialog_get_content_area( GTK_DIALOG( dialog ) ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_container_add( GTK_CONTAINER( content_area ), vbox ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); gtk_widget_show( vbox ); entry = gtk_entry_new(); gtk_editable_set_editable( GTK_EDITABLE( entry ), FALSE ); gtk_box_pack_start( GTK_BOX( vbox ), entry, FALSE, FALSE, 0 ); gtk_widget_show( entry ); hbox = gtk_hbox_new( FALSE, 5 ); gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); check3d = gtk_check_button_new_with_label( _( "Show 3D" ) ); gtk_box_pack_start( GTK_BOX( hbox ), check3d, FALSE, FALSE, 0 ); gtk_widget_show( check3d ); check2d = gtk_check_button_new_with_label( _( "Show 2D" ) ); gtk_box_pack_start( GTK_BOX( hbox ), check2d, FALSE, FALSE, 0 ); gtk_widget_show( check2d ); change_button = button = gtk_button_new_with_label( _( "Change" ) ); gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); g_signal_connect( G_OBJECT( button ), "clicked", G_CALLBACK( change_clicked ), parent ); gtk_widget_show( button ); size_group = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); gtk_size_group_add_widget( size_group, ok_button ); gtk_size_group_add_widget( size_group, cancel_button ); gtk_size_group_add_widget( size_group, change_button ); g_object_unref( size_group ); char *fn = g_FuncTable.m_pfnGetMapName(); strcpy( portals.fn, fn ); fn = strrchr( portals.fn, '.' ); if ( fn != NULL ) { *fn = '\0'; strcat( portals.fn, ".prt" ); } gtk_entry_set_text( GTK_ENTRY( entry ), portals.fn ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( check2d ), portals.show_2d ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( check3d ), portals.show_3d ); response_id = gtk_dialog_run( GTK_DIALOG( dialog ) ); if( response_id == GTK_RESPONSE_OK ) { portals.Purge(); portals.show_3d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check3d ) ) ? true : false; portals.show_2d = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( check2d ) ) ? true : false; ret = IDOK; } else { ret = IDCANCEL; } gtk_widget_destroy( dialog ); return ret; }
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpTextOptions *options = GIMP_TEXT_OPTIONS (tool_options); GtkWidget *main_vbox = gimp_tool_options_gui (tool_options); GtkWidget *table; GtkWidget *vbox; GtkWidget *hbox; GtkWidget *button; GtkWidget *entry; GtkWidget *box; GtkWidget *spinbutton; GtkWidget *combo; GtkSizeGroup *size_group; gint row = 0; hbox = gimp_prop_font_box_new (NULL, GIMP_CONTEXT (tool_options), _("Font"), 2, "font-view-type", "font-view-size"); gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); table = gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); entry = gimp_prop_size_entry_new (config, "font-size", FALSE, "font-size-unit", "%p", GIMP_SIZE_ENTRY_UPDATE_SIZE, 72.0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Size:"), 0.0, 0.5, entry, 2, FALSE); options->size_entry = entry; vbox = gtk_vbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); button = gimp_prop_check_button_new (config, "use-editor", _("Use editor")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); button = gimp_prop_check_button_new (config, "antialias", _("Antialiasing")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); table = gtk_table_new (6, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 2); gtk_table_set_row_spacings (GTK_TABLE (table), 2); gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); row = 0; size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); button = gimp_prop_enum_combo_box_new (config, "hint-style", -1, -1); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Hinting:"), 0.0, 0.5, button, 1, TRUE); gtk_size_group_add_widget (size_group, button); button = gimp_prop_color_button_new (config, "foreground", _("Text Color"), 40, 24, GIMP_COLOR_AREA_FLAT); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), GIMP_CONTEXT (options)); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Color:"), 0.0, 0.5, button, 1, TRUE); gtk_size_group_add_widget (size_group, button); box = gimp_prop_enum_stock_box_new (config, "justify", "gtk-justify", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Justify:"), 0.0, 0.5, box, 2, TRUE); gtk_size_group_add_widget (size_group, box); g_object_unref (size_group); spinbutton = gimp_prop_spin_button_new (config, "indent", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GTK_STOCK_INDENT, spinbutton, 1, TRUE); spinbutton = gimp_prop_spin_button_new (config, "line-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GIMP_STOCK_LINE_SPACING, spinbutton, 1, TRUE); spinbutton = gimp_prop_spin_button_new (config, "letter-spacing", 1.0, 10.0, 1); gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 5); gimp_table_attach_stock (GTK_TABLE (table), row++, GIMP_STOCK_LETTER_SPACING, spinbutton, 1, TRUE); combo = gimp_prop_enum_combo_box_new (config, "box-mode", 0, 0); gimp_table_attach_aligned (GTK_TABLE (table), 0, row++, _("Box:"), 0.0, 0.5, combo, 1, TRUE); /* Only add the language entry if the iso-codes package is available. */ #ifdef HAVE_ISO_CODES { GtkWidget *label; vbox = gtk_vbox_new (FALSE, 2); gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0); gtk_widget_show (vbox); hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Language:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); entry = gimp_prop_language_entry_new (config, "language"); gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0); gtk_widget_show (entry); } #endif return main_vbox; }
int main( int argc, char *argv[] ) { GtkWidget *window = NULL; GtkWidget *box1; GtkWidget *box2; GtkWidget *button; GtkWidget *separator; GSList *group; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "delete-event", G_CALLBACK (close_application), NULL); gtk_window_set_title (GTK_WINDOW (window), "radio buttons"); gtk_container_set_border_width (GTK_CONTAINER (window), 0); box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); gtk_widget_show (box1); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0); gtk_widget_show (box2); button = gtk_radio_button_new_with_label (NULL, "button1"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); button = gtk_radio_button_new_with_label (group, "button2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (button), "button3"); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_show (button); separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0); gtk_widget_show (separator); box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE, 10); gtk_container_set_border_width (GTK_CONTAINER (box2), 10); gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0); gtk_widget_show (box2); button = gtk_button_new_with_label ("close"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (close_application), window); gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0); gtk_widget_set_can_default (button, TRUE); gtk_widget_grab_default (button); gtk_widget_show (button); gtk_widget_show (window); gtk_main (); return 0; }
int main( int argc, char *argv[] ) { /* GtkWidget is the storage type for widgets */ GtkWidget *window; GtkWidget *button; GtkWidget *box1; /* This is called in all GTK applications. Arguments are parsed * from the command line and are returned to the application. */ gtk_init (&argc, &argv); /* Create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* This is a new call, which just sets the title of our * new window to "Hello Buttons!" */ gtk_window_set_title (GTK_WINDOW (window), "Hello Buttons!"); /* Here we just set a handler for delete_event that immediately * exits GTK. */ g_signal_connect (window, "delete-event", G_CALLBACK (delete_event), NULL); /* Sets the border width of the window. */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* We create a box to pack widgets into. This is described in detail * in the "packing" section. The box is not really visible, it * is just used as a tool to arrange widgets. */ box1 = gtk_hbox_new (FALSE, 0); /* Put the box into the main window. */ gtk_container_add (GTK_CONTAINER (window), box1); /* Creates a new button with the label "Button 1". */ button = gtk_button_new_with_label ("Button 1"); /* Now when the button is clicked, we call the "callback" function * with a pointer to "button 1" as its argument */ g_signal_connect (button, "clicked", G_CALLBACK (callback), (gpointer) "button 1"); /* Instead of gtk_container_add, we pack this button into the invisible * box, which has been packed into the window. */ gtk_box_pack_start (GTK_BOX(box1), button, TRUE, TRUE, 0); /* Always remember this step, this tells GTK that our preparation for * this button is complete, and it can now be displayed. */ gtk_widget_show (button); /* Do these same steps again to create a second button */ button = gtk_button_new_with_label ("Button 2"); /* Call the same callback function with a different argument, * passing a pointer to "button 2" instead. */ g_signal_connect (button, "clicked", G_CALLBACK (callback), (gpointer) "button 2"); gtk_box_pack_start(GTK_BOX (box1), button, TRUE, TRUE, 0); /* The order in which we show the buttons is not really important, but I * recommend showing the window last, so it all pops up at once. */ gtk_widget_show (button); gtk_widget_show (box1); gtk_widget_show (window); /* Rest in gtk_main and wait for the fun to begin! */ gtk_main (); return 0; }
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; }
/*** *** Creates the simple application window with one *** drawing area that has an OpenGL-capable visual. ***/ static GtkWidget * create_window (GdkGLConfig *glconfig) { GtkWidget *window; GtkWidget *vbox; GtkWidget *drawing_area; GtkWidget *menu; GtkWidget *button; /* * Top-level window. */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), DEFAULT_TITLE); /* Get automatically redrawn if any of their children changed allocation. */ gtk_container_set_reallocate_redraws (GTK_CONTAINER (window), TRUE); /* Connect signal handlers to the window */ g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL); /* * VBox. */ vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); /* * Drawing area to draw OpenGL scene. */ drawing_area = gtk_drawing_area_new (); gtk_widget_set_size_request (drawing_area, DEFAULT_WIDTH, DEFAULT_HEIGHT); /* Set OpenGL-capability to the widget */ gtk_widget_set_gl_capability (drawing_area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_add_events (drawing_area, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_VISIBILITY_NOTIFY_MASK); /* Connect signal handlers to the drawing area */ g_signal_connect_after (G_OBJECT (drawing_area), "realize", G_CALLBACK (realize), NULL); g_signal_connect (G_OBJECT (drawing_area), "configure_event", G_CALLBACK (configure_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "draw", G_CALLBACK (draw), NULL); g_signal_connect (G_OBJECT (drawing_area), "motion_notify_event", G_CALLBACK (motion_notify_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "button_press_event", G_CALLBACK (button_press_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "unrealize", G_CALLBACK (unrealize), NULL); /* key_press_event handler for top-level window */ g_signal_connect_swapped (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), drawing_area); /* For idle function. */ g_signal_connect (G_OBJECT (drawing_area), "map_event", G_CALLBACK (map_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "unmap_event", G_CALLBACK (unmap_event), NULL); g_signal_connect (G_OBJECT (drawing_area), "visibility_notify_event", G_CALLBACK (visibility_notify_event), NULL); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_widget_show (drawing_area); /* * Popup menu. */ menu = create_popup_menu (drawing_area); g_signal_connect_swapped (G_OBJECT (drawing_area), "button_press_event", G_CALLBACK (button_press_event_popup_menu), menu); /* * Simple quit button. */ button = gtk_button_new_with_label ("Quit"); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (gtk_main_quit), NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); return window; }