void gui_init(dt_lib_module_t *self) { /* initialize ui widgets */ dt_lib_import_t *d = (dt_lib_import_t *)g_malloc(sizeof(dt_lib_import_t)); memset(d,0,sizeof(dt_lib_import_t)); self->data = (void *)d; self->widget = gtk_vbox_new(FALSE, 5); /* add import singel image buttons */ GtkWidget *widget = gtk_button_new_with_label(_("image")); d->import_file = GTK_BUTTON(widget); gtk_button_set_alignment(GTK_BUTTON(widget), 0.05, 5); gtk_widget_set_tooltip_text(widget, _("select one or more images to import")); gtk_widget_set_can_focus(widget, TRUE); gtk_widget_set_receives_default(widget, TRUE); gtk_box_pack_start(GTK_BOX(self->widget), widget, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (_lib_import_single_image_callback), self); /* adding the import folder button */ widget = gtk_button_new_with_label(_("folder")); d->import_directory = GTK_BUTTON(widget); gtk_button_set_alignment(GTK_BUTTON(widget), 0.05, 5); gtk_widget_set_tooltip_text(widget, _("select a folder to import as film roll")); gtk_widget_set_can_focus(widget, TRUE); gtk_widget_set_receives_default(widget, TRUE); gtk_box_pack_start(GTK_BOX(self->widget), widget, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (_lib_import_folder_callback), self); #ifdef HAVE_GPHOTO2 /* add devices container for cameras */ d->devices = GTK_BOX(gtk_vbox_new(FALSE,5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->devices), FALSE, FALSE, 0); /* initialize camctl listener and update devices */ d->camctl_listener.data = self; d->camctl_listener.control_status = _camctl_camera_control_status_callback; d->camctl_listener.camera_disconnected = _camctl_camera_disconnected_callback; dt_camctl_register_listener(darktable.camctl, &d->camctl_listener ); _lib_import_ui_devices_update(self); #endif }
static int gtkToggleSetAlignmentAttrib(Ihandle* ih, const char* value) { GtkButton* button = (GtkButton*)ih->handle; float xalign, yalign; char value1[30]="", value2[30]=""; if (ih->data->type == IUP_TOGGLE_TEXT) return 0; iupStrToStrStr(value, value1, value2, ':'); if (iupStrEqualNoCase(value1, "ARIGHT")) xalign = 1.0f; else if (iupStrEqualNoCase(value1, "ACENTER")) xalign = 0.5f; else /* "ALEFT" */ xalign = 0; if (iupStrEqualNoCase(value2, "ABOTTOM")) yalign = 1.0f; else if (iupStrEqualNoCase(value2, "ATOP")) yalign = 0; else /* ACENTER (default) */ yalign = 0.5f; gtk_button_set_alignment(button, xalign, yalign); return 1; }
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxButton creation failed") ); return false; } m_widget = gtk_button_new_with_mnemonic(""); float x_alignment = 0.5; if (HasFlag(wxBU_LEFT)) x_alignment = 0.0; else if (HasFlag(wxBU_RIGHT)) x_alignment = 1.0; float y_alignment = 0.5; if (HasFlag(wxBU_TOP)) y_alignment = 0.0; else if (HasFlag(wxBU_BOTTOM)) y_alignment = 1.0; #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment); } else #endif { if (GTK_IS_MISC(GTK_BIN(m_widget)->child)) gtk_misc_set_alignment(GTK_MISC(GTK_BIN(m_widget)->child), x_alignment, y_alignment); } SetLabel(label); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); g_signal_connect_after (m_widget, "clicked", G_CALLBACK (gtk_button_clicked_callback), this); g_signal_connect_after (m_widget, "style_set", G_CALLBACK (gtk_button_style_set_callback), this); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxString& url, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( UseNative() ) { // do validation checks: CheckParams(label, url, style); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxHyperlinkCtrl creation failed") ); return false; } m_widget = gtk_link_button_new("asdfsaf asdfdsaf asdfdsa"); g_object_ref(m_widget); gtk_widget_show(m_widget); // alignment float x_alignment = 0.5; if (HasFlag(wxHL_ALIGN_LEFT)) x_alignment = 0.0; else if (HasFlag(wxHL_ALIGN_RIGHT)) x_alignment = 1.0; gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5); // set to non empty strings both the url and the label SetURL(url.empty() ? label : url); SetLabel(label.empty() ? url : label); // our signal handlers: g_signal_connect_after (m_widget, "clicked", G_CALLBACK (gtk_hyperlink_clicked_callback), this); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); // wxWindowGTK will connect to the enter_notify and leave_notify GTK+ signals // thus overriding GTK+'s internal signal handlers which set the cursor of // the widget - thus we need to manually set it here: SetCursor(wxCursor(wxCURSOR_HAND)); } else return wxGenericHyperlinkCtrl::Create(parent, id, label, url, pos, size, style, name); return true; }
static GtkWidget * go_color_palette_setup (GOColorPalette *pal, char const *no_color_label, int cols, int rows, GONamedColor const *color_names) { GtkWidget *w, *grid; int pos, row, col = 0; grid = gtk_grid_new (); if (no_color_label != NULL) { w = gtk_button_new_with_label (no_color_label); gtk_widget_set_hexpand (w, TRUE); gtk_grid_attach (GTK_GRID (grid), w, 0, 0, cols, 1); g_signal_connect (w, "button_release_event", G_CALLBACK (cb_default_release_event), pal); } for (row = 0; row < rows; row++) for (col = 0; col < cols; col++) { pos = row * cols + col; if (color_names [pos].name == NULL) goto custom_colors; go_color_palette_button_new ( pal, GTK_GRID (grid), &(color_names [pos]), col, row + 1); } custom_colors : if (col > 0) row++; for (col = 0; col < cols && col < GO_COLOR_GROUP_HISTORY_SIZE; col++) { GONamedColor color_name = { 0, N_("custom") }; color_name.color = pal->group->history [col]; pal->swatches [col] = go_color_palette_button_new (pal, GTK_GRID (grid), &color_name, col, row + 1); } w = go_gtk_button_build_with_stock (_("Custom color..."), GTK_STOCK_SELECT_COLOR); gtk_button_set_alignment (GTK_BUTTON (w), 0., .5); gtk_widget_set_hexpand (w, TRUE); gtk_grid_attach (GTK_GRID (grid), w, 0, row + 2, cols, 1); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_combo_custom_clicked), pal); return grid; }
static int gtkButtonSetAlignmentAttrib(Ihandle* ih, const char* value) { GtkButton* button = (GtkButton*)ih->handle; PangoAlignment alignment; float xalign, yalign; char value1[30]="", value2[30]=""; if (iupAttribGet(ih, "_IUPGTK_EVENTBOX")) return 0; iupStrToStrStr(value, value1, value2, ':'); if (iupStrEqualNoCase(value1, "ARIGHT")) { xalign = 1.0f; alignment = PANGO_ALIGN_RIGHT; } else if (iupStrEqualNoCase(value1, "ACENTER")) { xalign = 0.5f; alignment = PANGO_ALIGN_CENTER; } else /* "ALEFT" */ { xalign = 0; alignment = PANGO_ALIGN_LEFT; } if (iupStrEqualNoCase(value2, "ABOTTOM")) yalign = 1.0f; else if (iupStrEqualNoCase(value2, "ATOP")) yalign = 0; else /* ACENTER (default) */ yalign = 0.5f; gtk_button_set_alignment(button, xalign, yalign); if (ih->data->type == IUP_BUTTON_TEXT) /* text only */ { GtkLabel* label = gtkButtonGetLabel(ih); if (label) { PangoLayout* layout = gtk_label_get_layout(label); if (layout) pango_layout_set_alignment(layout, alignment); } } return 1; }
static GtkWidget *slist_new_item(slist *lst, const char *label, int row) { GtkWidget *item; item = gtk_button_new_with_label(label); gtk_widget_set_name(item, "white_button"); slist_set_row(item, row); gtk_button_set_relief(GTK_BUTTON(item), GTK_RELIEF_HALF); #if HAVE_GTK_BUTTON_SET_ALIGNMENT gtk_button_set_alignment(GTK_BUTTON(item), 0.05, 1.0); #endif gtk_box_pack_start(GTK_BOX(lst->topics), item, false, false, 0); SG_SIGNAL_CONNECT(item, "clicked", slist_item_clicked, (gpointer)lst); SG_SIGNAL_CONNECT(item, "button_press_event", slist_item_button_pressed, (gpointer)lst); gtk_widget_show(item); return(item); }
static GtkWidget * anjuta_starter_button_new (const gchar *label) { GtkWidget *button; gchar *markup; GtkWidget *widget; markup = g_markup_printf_escaped ("<span underline=\"single\" foreground=\"#5a7ac7\">%s</span>", label); button = gtk_button_new_with_label (markup); widget = gtk_bin_get_child (GTK_BIN (button)); gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); g_free (markup); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_alignment (GTK_BUTTON (button), 0.0, 0.5); return button; }
static void tpaw_calendar_button_init (TpawCalendarButton *self) { GtkWidget *image; GtkStyleContext *context; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_CALENDAR_BUTTON, TpawCalendarButtonPriv); context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED); /* Date */ self->priv->button_date = gtk_button_new (); g_signal_connect (self->priv->button_date, "clicked", G_CALLBACK (tpaw_calendar_button_date_clicked), self); gtk_button_set_alignment (GTK_BUTTON (self->priv->button_date), 0, 0.5); gtk_box_pack_start (GTK_BOX (self), self->priv->button_date, TRUE, TRUE, 0); gtk_widget_show (self->priv->button_date); /* Clear */ self->priv->button_clear = gtk_button_new (); image = gtk_image_new_from_icon_name ("edit-clear-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_image (GTK_BUTTON (self->priv->button_clear), image); gtk_widget_show (image); g_signal_connect (self->priv->button_clear, "clicked", G_CALLBACK (tpaw_calendar_button_clear_clicked), self); gtk_box_pack_start (GTK_BOX (self), self->priv->button_clear, FALSE, FALSE, 0); gtk_widget_show (self->priv->button_clear); }
/** * @fn ControlData* gui_control(Tab*) * * Constructor is used to create ControlData data structure. * @param tab The tab structure used by the widget * @return The Filter viewer data created. */ ControlData* gui_control(LttvPluginTab *ptab) { Tab *tab = ptab->tab; g_debug("filter::gui_control()"); ControlData* tcd = g_new(ControlData,1); tcd->tab = tab; tcd->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(tcd->window), "LTTng Trace Control"); /* * Initiating GtkTable layout * starts with 2 rows and 5 columns and * expands when expressions added */ tcd->main_box = gtk_table_new(14,7,FALSE); gtk_table_set_row_spacings(GTK_TABLE(tcd->main_box),5); gtk_table_set_col_spacings(GTK_TABLE(tcd->main_box),5); gtk_container_add(GTK_CONTAINER(tcd->window), GTK_WIDGET(tcd->main_box)); GList *focus_chain = NULL; /* * start/pause/stop buttons */ GdkPixbuf *pixbuf; GtkWidget *image; pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->ltt_armall_button = gtk_button_new_with_label("Arm LTTng kernel probes"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->ltt_armall_button), image); g_object_set(G_OBJECT(tcd->ltt_armall_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->ltt_armall_button), 0.0, 0.0); gtk_widget_show (tcd->ltt_armall_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_armall_button,6,7,0,1,GTK_FILL,GTK_FILL,2,2); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->ltt_disarmall_button = gtk_button_new_with_label("Disarm LTTng kernel probes"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->ltt_disarmall_button), image); g_object_set(G_OBJECT(tcd->ltt_disarmall_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->ltt_disarmall_button), 0.0, 0.0); gtk_widget_show (tcd->ltt_disarmall_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_disarmall_button,6,7,1,2,GTK_FILL,GTK_FILL,2,2); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStart_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->start_button = gtk_button_new_with_label("start"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->start_button), image); g_object_set(G_OBJECT(tcd->start_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->start_button), 0.0, 0.0); gtk_widget_show (tcd->start_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_button,6,7,2,3,GTK_FILL,GTK_FILL,2,2); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->pause_button = gtk_button_new_with_label("pause"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->pause_button), image); g_object_set(G_OBJECT(tcd->pause_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->pause_button), 0.0, 0.0); gtk_widget_show (tcd->pause_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->pause_button,6,7,3,4,GTK_FILL,GTK_FILL,2,2); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlPause_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->unpause_button = gtk_button_new_with_label("unpause"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->unpause_button), image); g_object_set(G_OBJECT(tcd->unpause_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->unpause_button), 0.0, 0.0); gtk_widget_show (tcd->unpause_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->unpause_button,6,7,4,5,GTK_FILL,GTK_FILL,2,2); pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)TraceControlStop_xpm); image = gtk_image_new_from_pixbuf(pixbuf); tcd->stop_button = gtk_button_new_with_label("stop"); //2.6 gtk_button_set_image(GTK_BUTTON(tcd->stop_button), image); g_object_set(G_OBJECT(tcd->stop_button), "image", image, NULL); gtk_button_set_alignment(GTK_BUTTON(tcd->stop_button), 0.0, 0.0); gtk_widget_show (tcd->stop_button); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->stop_button,6,7,5,6,GTK_FILL,GTK_FILL,2,2); /* * First half of the filter window * - textual entry of filter expression * - processing button */ tcd->username_label = gtk_label_new("Username:"******"root"); gtk_widget_show (tcd->username_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->username_label,0,2,0,1,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->username_entry,2,6,0,1,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->password_label = gtk_label_new("Password:"******"Channel directory:"); gtk_widget_show (tcd->channel_dir_label); tcd->channel_dir_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->channel_dir_entry),"/mnt/debugfs/ltt"); gtk_widget_show (tcd->channel_dir_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->channel_dir_label,0,2,2,3,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->channel_dir_entry,2,6,2,3,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->trace_dir_label = gtk_label_new("Trace directory:"); gtk_widget_show (tcd->trace_dir_label); tcd->trace_dir_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->trace_dir_entry),"/tmp/trace1"); gtk_widget_show (tcd->trace_dir_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_dir_label,0,2,3,4,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_dir_entry,2,6,3,4,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->trace_name_label = gtk_label_new("Trace name:"); gtk_widget_show (tcd->trace_name_label); tcd->trace_name_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->trace_name_entry),"trace"); gtk_widget_show (tcd->trace_name_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_name_label,0,2,4,5,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_name_entry,2,6,4,5,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->trace_mode_label = gtk_label_new("Trace mode "); gtk_widget_show (tcd->trace_mode_label); tcd->trace_mode_combo = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(tcd->trace_mode_combo), "normal"); gtk_combo_box_append_text(GTK_COMBO_BOX(tcd->trace_mode_combo), "flight recorder"); gtk_combo_box_set_active(GTK_COMBO_BOX(tcd->trace_mode_combo), 0); gtk_widget_show (tcd->trace_mode_combo); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_mode_label,0,2,5,6,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->trace_mode_combo,2,6,5,6,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->start_daemon_label = gtk_label_new("Start daemon "); gtk_widget_show (tcd->start_daemon_label); tcd->start_daemon_check = gtk_check_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tcd->start_daemon_check), TRUE); gtk_widget_show (tcd->start_daemon_check); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_label,0,2,6,7,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->start_daemon_check,2,6,6,7,GTK_FILL,GTK_FILL,0,0); tcd->append_label = gtk_label_new("Append to trace "); gtk_widget_show (tcd->append_label); tcd->append_check = gtk_check_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tcd->append_check), FALSE); gtk_widget_show (tcd->append_check); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->append_label,0,2,7,8,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->append_check,2,6,7,8,GTK_FILL,GTK_FILL,0,0); tcd->optional_label = gtk_label_new("Optional fields "); gtk_widget_show (tcd->optional_label); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->optional_label,0,6,8,9,GTK_FILL,GTK_FILL,2,2); tcd->subbuf_size_label = gtk_label_new("Subbuffer size:"); gtk_widget_show (tcd->subbuf_size_label); tcd->subbuf_size_entry = gtk_entry_new(); gtk_widget_show (tcd->subbuf_size_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_label,0,2,9,10,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_size_entry,2,6,9,10,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->subbuf_num_label = gtk_label_new("Number of subbuffers:"); gtk_widget_show (tcd->subbuf_num_label); tcd->subbuf_num_entry = gtk_entry_new(); gtk_widget_show (tcd->subbuf_num_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_label,0,2,10,11,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->subbuf_num_entry,2,6,10,11,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->lttd_threads_label = gtk_label_new("Number of lttd threads:"); gtk_widget_show (tcd->lttd_threads_label); tcd->lttd_threads_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->lttd_threads_entry), "1"); gtk_widget_show (tcd->lttd_threads_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_threads_label,0,2,11,12,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_threads_entry,2,6,11,12,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->lttctl_path_label = gtk_label_new("path to lttctl:"); gtk_widget_show (tcd->lttctl_path_label); tcd->lttctl_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->lttctl_path_entry),PACKAGE_BIN_DIR "/lttctl"); gtk_widget_show (tcd->lttctl_path_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_label,0,2,12,13,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttctl_path_entry,2,6,12,13,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->lttd_path_label = gtk_label_new("path to lttd:"); gtk_widget_show (tcd->lttd_path_label); tcd->lttd_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->lttd_path_entry),PACKAGE_BIN_DIR "/lttd"); gtk_widget_show (tcd->lttd_path_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_label,0,2,13,14,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->lttd_path_entry,2,6,13,14,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->ltt_armall_path_label = gtk_label_new("path to ltt_armall:"); gtk_widget_show (tcd->ltt_armall_path_label); tcd->ltt_armall_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->ltt_armall_path_entry),PACKAGE_BIN_DIR "/ltt-armall"); gtk_widget_show (tcd->ltt_armall_path_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_armall_path_label,0,2,14,15,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_armall_path_entry,2,6,14,15,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); tcd->ltt_disarmall_path_label = gtk_label_new("path to ltt_disarmall:"); gtk_widget_show (tcd->ltt_disarmall_path_label); tcd->ltt_disarmall_path_entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(tcd->ltt_disarmall_path_entry),PACKAGE_BIN_DIR "/ltt-disarmall"); gtk_widget_show (tcd->ltt_disarmall_path_entry); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_disarmall_path_label,0,2,15,16,GTK_FILL,GTK_FILL,2,2); gtk_table_attach( GTK_TABLE(tcd->main_box),tcd->ltt_disarmall_path_entry,2,6,15,16,GTK_FILL|GTK_EXPAND|GTK_SHRINK,GTK_FILL,0,0); focus_chain = g_list_append (focus_chain, tcd->username_entry); focus_chain = g_list_append (focus_chain, tcd->password_entry); focus_chain = g_list_append (focus_chain, tcd->ltt_armall_path_entry); focus_chain = g_list_append (focus_chain, tcd->ltt_disarmall_path_entry); focus_chain = g_list_append (focus_chain, tcd->start_button); focus_chain = g_list_append (focus_chain, tcd->pause_button); focus_chain = g_list_append (focus_chain, tcd->unpause_button); focus_chain = g_list_append (focus_chain, tcd->stop_button); focus_chain = g_list_append (focus_chain, tcd->channel_dir_entry); focus_chain = g_list_append (focus_chain, tcd->trace_dir_entry); focus_chain = g_list_append (focus_chain, tcd->trace_name_entry); focus_chain = g_list_append (focus_chain, tcd->trace_mode_combo); focus_chain = g_list_append (focus_chain, tcd->start_daemon_check); focus_chain = g_list_append (focus_chain, tcd->append_check); focus_chain = g_list_append (focus_chain, tcd->subbuf_size_entry); focus_chain = g_list_append (focus_chain, tcd->subbuf_num_entry); focus_chain = g_list_append (focus_chain, tcd->lttd_threads_entry); focus_chain = g_list_append (focus_chain, tcd->lttctl_path_entry); focus_chain = g_list_append (focus_chain, tcd->lttd_path_entry); gtk_container_set_focus_chain(GTK_CONTAINER(tcd->main_box), focus_chain); g_list_free(focus_chain); g_signal_connect(G_OBJECT(tcd->start_button), "clicked", (GCallback)start_clicked, tcd); g_signal_connect(G_OBJECT(tcd->pause_button), "clicked", (GCallback)pause_clicked, tcd); g_signal_connect(G_OBJECT(tcd->unpause_button), "clicked", (GCallback)unpause_clicked, tcd); g_signal_connect(G_OBJECT(tcd->stop_button), "clicked", (GCallback)stop_clicked, tcd); g_signal_connect(G_OBJECT(tcd->ltt_armall_button), "clicked", (GCallback)arm_clicked, tcd); g_signal_connect(G_OBJECT(tcd->ltt_disarmall_button), "clicked", (GCallback)disarm_clicked, tcd); /* * show main container */ gtk_widget_show(tcd->main_box); gtk_widget_show(tcd->window); g_object_set_data_full( G_OBJECT(guicontrol_get_widget(tcd)), "control_viewer_data", tcd, (GDestroyNotify)gui_control_destructor); g_control_list = g_slist_append( g_control_list, tcd); return tcd; }
/* Main program. */ int main(int argc, char * argv[]) { #ifdef ENABLE_NLS setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif /* Initialize GTK (via g_option_context_parse) and parse command line arguments. */ GOptionContext * context = g_option_context_new(""); g_option_context_add_main_entries(context, opt_entries, GETTEXT_PACKAGE); g_option_context_add_group(context, gtk_get_option_group(TRUE)); GError * err = NULL; if ( ! g_option_context_parse(context, &argc, &argv, &err)) { g_print(_("Error: %s\n"), err->message); g_error_free(err); return 1; } g_option_context_free(context); HandlerContext handler_context; memset(&handler_context, 0, sizeof(handler_context)); /* Get the lxsession PID. */ const char * p = g_getenv("_LXSESSION_PID"); if (p != NULL) handler_context.lxsession_pid = atoi(p); /* Initialize capabilities of the systemd mechanism. */ if (dbus_systemd_CanPowerOff()) { handler_context.shutdown_available = TRUE; handler_context.shutdown_systemd = TRUE; } if (dbus_systemd_CanReboot()) { handler_context.reboot_available = TRUE; handler_context.reboot_systemd = TRUE; } if (dbus_systemd_CanSuspend()) { handler_context.suspend_available = TRUE; handler_context.suspend_systemd = TRUE; } if (dbus_systemd_CanHibernate()) { handler_context.hibernate_available = TRUE; handler_context.hibernate_systemd = TRUE; } /* Initialize capabilities of the ConsoleKit mechanism. */ if (!handler_context.shutdown_available && dbus_ConsoleKit_CanStop()) { handler_context.shutdown_available = TRUE; handler_context.shutdown_ConsoleKit = TRUE; } if (!handler_context.reboot_available && dbus_ConsoleKit_CanRestart()) { handler_context.reboot_available = TRUE; handler_context.reboot_ConsoleKit = TRUE; } /* Initialize capabilities of the UPower mechanism. */ if (!handler_context.suspend_available && dbus_UPower_CanSuspend()) { handler_context.suspend_available = TRUE; handler_context.suspend_UPower = TRUE; } if (!handler_context.hibernate_available && dbus_UPower_CanHibernate()) { handler_context.hibernate_available = TRUE; handler_context.hibernate_UPower = TRUE; } /* If we are under GDM, its "Switch User" is available. */ if (verify_running("gdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* If we are under GDM3, its "Switch User" is available. */ if (verify_running("gdm3", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm also use gdmflexiserver */ if (verify_running("lightdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm also use gdmflexiserver */ if (verify_running("lightdm", "gdmflexiserver")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_GDM = TRUE; } /* lightdm can also be find by the env */ if (g_getenv("XDG_SEAT_PATH")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_LIGHTDM = TRUE; } /* If we are under KDM, its "Switch User" is available. */ if (verify_running("kdm", "kdmctl")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_KDM = TRUE; } if (verify_running("lxdm", "lxdm-binary")) { handler_context.switch_user_available = TRUE; handler_context.switch_user_LXDM = TRUE; } /* LTSP support */ if (g_getenv("LTSP_CLIENT")) { handler_context.ltsp = TRUE; handler_context.shutdown_available = TRUE; handler_context.reboot_available = TRUE; } /* Lock screen */ const gchar* very_lock_screen = determine_lock_screen(); if (very_lock_screen) { handler_context.lock_screen = TRUE; } /* Make the button images accessible. */ gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/lxsession/images"); /* Get the background pixbuf. */ GdkPixbuf * pixbuf = get_background_pixbuf(); /* Create the toplevel window. */ GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_fullscreen(GTK_WINDOW(window)); GdkScreen* screen = gtk_widget_get_screen(window); gtk_window_set_default_size(GTK_WINDOW(window), gdk_screen_get_width(screen), gdk_screen_get_height(screen)); gtk_widget_set_app_paintable(window, TRUE); g_signal_connect(G_OBJECT(window), "expose_event", G_CALLBACK(expose_event), pixbuf); /* Toplevel container */ GtkWidget* alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); gtk_container_add(GTK_CONTAINER(window), alignment); GtkWidget* center_area = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(alignment), center_area); GtkWidget* center_vbox = gtk_vbox_new(FALSE, 6); gtk_container_set_border_width(GTK_CONTAINER(center_vbox), 12); gtk_container_add(GTK_CONTAINER(center_area), center_vbox); GtkWidget* controls = gtk_vbox_new(FALSE, 6); /* If specified, apply a user-specified banner image. */ if (banner_path != NULL) { GtkWidget * banner_image = gtk_image_new_from_file(banner_path); GtkPositionType banner_position = get_banner_position(); switch (banner_position) { case GTK_POS_LEFT: case GTK_POS_RIGHT: { /* Create a horizontal box to contain the image and the controls. */ GtkWidget * box = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), box, FALSE, FALSE, 0); /* Pack the image and a separator. */ gtk_misc_set_alignment(GTK_MISC(banner_image), 0.5, 0.0); if (banner_position == GTK_POS_LEFT) { gtk_box_pack_start(GTK_BOX(box), banner_image, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2); } else { gtk_box_pack_start(GTK_BOX(box), controls, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(box), gtk_vseparator_new(), FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(box), banner_image, FALSE, FALSE, 2); } } break; case GTK_POS_TOP: gtk_box_pack_start(GTK_BOX(controls), banner_image, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); break; case GTK_POS_BOTTOM: gtk_box_pack_end(GTK_BOX(controls), banner_image, FALSE, FALSE, 2); gtk_box_pack_end(GTK_BOX(controls), gtk_hseparator_new(), FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); break; } } else gtk_box_pack_start(GTK_BOX(center_vbox), controls, FALSE, FALSE, 0); /* Create the label. */ GtkWidget * label = gtk_label_new(""); if (prompt == NULL) { const char * session_name = g_getenv("DESKTOP_SESSION"); if (session_name == NULL) session_name = "LXDE"; const gchar *command_line = "lsb_release -r -s"; gchar *output = NULL; GError *error; if (!g_spawn_command_line_sync( command_line, &output, NULL, NULL, &error)) { fprintf (stderr, "Error: %s\n", error->message); g_error_free (error); } if (output == NULL) { output = ""; } else { output[strlen ( output ) - 1] = '\0'; } prompt = g_strdup_printf(_("<b><big>Logout %s %s session ?</big></b>"), session_name, output); } gtk_label_set_markup(GTK_LABEL(label), prompt); gtk_box_pack_start(GTK_BOX(controls), label, FALSE, FALSE, 4); /* Create the Shutdown button. */ if (handler_context.shutdown_available) { GtkWidget * shutdown_button = gtk_button_new_with_mnemonic(_("Sh_utdown")); GtkWidget * image = gtk_image_new_from_icon_name("system-shutdown", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(shutdown_button), image); gtk_button_set_alignment(GTK_BUTTON(shutdown_button), 0.0, 0.5); g_signal_connect(G_OBJECT(shutdown_button), "clicked", G_CALLBACK(shutdown_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), shutdown_button, FALSE, FALSE, 4); } /* Create the Reboot button. */ if (handler_context.reboot_available) { GtkWidget * reboot_button = gtk_button_new_with_mnemonic(_("_Reboot")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-reboot", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(reboot_button), image); gtk_button_set_alignment(GTK_BUTTON(reboot_button), 0.0, 0.5); g_signal_connect(G_OBJECT(reboot_button), "clicked", G_CALLBACK(reboot_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), reboot_button, FALSE, FALSE, 4); } /* Create the Suspend button. */ if (handler_context.suspend_available && !handler_context.ltsp) { GtkWidget * suspend_button = gtk_button_new_with_mnemonic(_("_Suspend")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-suspend", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(suspend_button), image); gtk_button_set_alignment(GTK_BUTTON(suspend_button), 0.0, 0.5); g_signal_connect(G_OBJECT(suspend_button), "clicked", G_CALLBACK(suspend_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), suspend_button, FALSE, FALSE, 4); } /* Create the Hibernate button. */ if (handler_context.hibernate_available && !handler_context.ltsp) { GtkWidget * hibernate_button = gtk_button_new_with_mnemonic(_("_Hibernate")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-hibernate", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(hibernate_button), image); gtk_button_set_alignment(GTK_BUTTON(hibernate_button), 0.0, 0.5); g_signal_connect(G_OBJECT(hibernate_button), "clicked", G_CALLBACK(hibernate_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), hibernate_button, FALSE, FALSE, 4); } /* Create the Switch User button. */ if (handler_context.switch_user_available && !handler_context.ltsp) { GtkWidget * switch_user_button = gtk_button_new_with_mnemonic(_("S_witch User")); GtkWidget * image = gtk_image_new_from_icon_name("gnome-session-switch", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(switch_user_button), image); gtk_button_set_alignment(GTK_BUTTON(switch_user_button), 0.0, 0.5); g_signal_connect(G_OBJECT(switch_user_button), "clicked", G_CALLBACK(switch_user_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), switch_user_button, FALSE, FALSE, 4); } /* Create the Lock Screen button. */ if (handler_context.lock_screen && !handler_context.ltsp) { GtkWidget * lock_screen_button = gtk_button_new_with_mnemonic(_("L_ock Screen")); GtkWidget * image = gtk_image_new_from_icon_name("system-lock-screen", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(lock_screen_button), image); gtk_button_set_alignment(GTK_BUTTON(lock_screen_button), 0.0, 0.5); g_signal_connect(G_OBJECT(lock_screen_button), "clicked", G_CALLBACK(lock_screen_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), lock_screen_button, FALSE, FALSE, 4); } /* Create the Logout button. */ GtkWidget * logout_button = gtk_button_new_with_mnemonic(_("_Logout")); GtkWidget * image = gtk_image_new_from_icon_name("system-log-out", GTK_ICON_SIZE_BUTTON); gtk_button_set_image(GTK_BUTTON(logout_button), image); gtk_button_set_alignment(GTK_BUTTON(logout_button), 0.0, 0.5); g_signal_connect(G_OBJECT(logout_button), "clicked", G_CALLBACK(logout_clicked), &handler_context); gtk_box_pack_start(GTK_BOX(controls), logout_button, FALSE, FALSE, 4); /* Create the Cancel button. */ GtkWidget * cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_button_set_alignment(GTK_BUTTON(cancel_button), 0.0, 0.5); g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(cancel_clicked), NULL); gtk_box_pack_start(GTK_BOX(controls), cancel_button, FALSE, FALSE, 4); /* Create the error text. */ handler_context.error_label = gtk_label_new(""); gtk_label_set_justify(GTK_LABEL(handler_context.error_label), GTK_JUSTIFY_CENTER); gtk_box_pack_start(GTK_BOX(controls), handler_context.error_label, FALSE, FALSE, 4); /* Show everything. */ gtk_widget_show_all(window); /* Run the main event loop. */ gtk_main(); /* Return. */ return 0; }
GtkWidget * create_dialog (void) { GtkWidget *dlg; GtkWidget *hbox, *vbox, *hbox2, *bbox; GtkWidget *image; GtkWidget *text; GtkWidget *main_widget = NULL; GtkWidget *topb = NULL; /* create dialog window */ dlg = gtk_dialog_new (); if (options.data.splash) gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); else gtk_window_set_type_hint (GTK_WINDOW (dlg), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_title (GTK_WINDOW (dlg), options.data.dialog_title); gtk_widget_set_name (dlg, "yad-dialog-window"); #ifndef G_OS_WIN32 if (options.parent) { gdk_window_set_transient_for (gtk_widget_get_window (dlg), gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), options.parent)); } #endif if (options.data.no_escape) g_signal_connect (G_OBJECT (dlg), "close", G_CALLBACK (ignore_close_cb) , NULL); /* get buttons container */ bbox = gtk_dialog_get_action_area (GTK_DIALOG (dlg)); /* set window icon */ if (options.data.window_icon) { if (g_file_test (options.data.window_icon, G_FILE_TEST_EXISTS)) gtk_window_set_icon_from_file (GTK_WINDOW (dlg), options.data.window_icon, NULL); else gtk_window_set_icon_name (GTK_WINDOW (dlg), options.data.window_icon); } /* set window borders */ if (options.data.borders == -1) options.data.borders = (gint) gtk_container_get_border_width (GTK_CONTAINER (dlg)); gtk_container_set_border_width (GTK_CONTAINER (dlg), (guint) options.data.borders); /* set window size and position */ if (!options.data.geometry && !options.data.maximized && !options.data.fullscreen) { gtk_window_set_default_size (GTK_WINDOW (dlg), options.data.width, options.data.height); if (options.data.center) gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); else if (options.data.mouse) gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); } /* set window behavior */ if (options.data.sticky) gtk_window_stick (GTK_WINDOW (dlg)); gtk_window_set_keep_above (GTK_WINDOW (dlg), options.data.ontop); gtk_window_set_decorated (GTK_WINDOW (dlg), !options.data.undecorated); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dlg), options.data.skip_taskbar); gtk_window_set_skip_pager_hint (GTK_WINDOW (dlg), options.data.skip_taskbar); /* create timeout indicator widget */ if (options.data.timeout) { if (G_LIKELY (options.data.to_indicator) && g_ascii_strcasecmp (options.data.to_indicator, "none")) { topb = gtk_progress_bar_new (); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (topb), 1.0); gtk_widget_set_name (topb, "yad-timeout-indicator"); } } /* add top label widgets */ #if !GTK_CHECK_VERSION(3,0,0) hbox = hbox2 = gtk_hbox_new (FALSE, 0); #else hbox = hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #endif gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), hbox, TRUE, TRUE, 5); #if !GTK_CHECK_VERSION(3,0,0) vbox = gtk_vbox_new (FALSE, 0); #else vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); #endif /* add timeout indicator */ if (topb) { if (g_ascii_strcasecmp (options.data.to_indicator, "top") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_LEFT_TO_RIGHT); #endif gtk_box_pack_start (GTK_BOX (vbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "bottom") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_LEFT_TO_RIGHT); #endif gtk_box_pack_end (GTK_BOX (vbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "left") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_BOTTOM_TO_TOP); #endif gtk_box_pack_start (GTK_BOX (hbox), topb, FALSE, FALSE, 2); } else if (g_ascii_strcasecmp (options.data.to_indicator, "right") == 0) { #if !GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (topb), GTK_PROGRESS_BOTTOM_TO_TOP); #endif gtk_box_pack_end (GTK_BOX (hbox), topb, FALSE, FALSE, 2); } if (settings.show_remain) { gchar *lbl = g_strdup_printf (_("%d sec"), options.data.timeout); #if GTK_CHECK_VERSION(3,0,0) gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (topb), TRUE); #endif gtk_progress_bar_set_text (GTK_PROGRESS_BAR (topb), lbl); g_free (lbl); } } /* must be after indicator! */ gtk_box_pack_end (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); if (options.data.image_on_top) { #if !GTK_CHECK_VERSION(3,0,0) hbox2 = gtk_hbox_new (FALSE, 0); #else hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); #endif gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0); } if (options.data.dialog_image) { GdkPixbuf *pb = NULL; pb = get_pixbuf (options.data.dialog_image, YAD_BIG_ICON); image = gtk_image_new_from_pixbuf (pb); if (pb) g_object_unref (pb); gtk_widget_set_name (image, "yad-dialog-image"); gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); gtk_box_pack_start (GTK_BOX (hbox2), image, FALSE, FALSE, 2); } if (options.data.dialog_text) { /* for dnd's tooltip we don't need text label */ if (options.mode != YAD_MODE_DND || !options.dnd_data.tooltip) { gchar *buf = g_strcompress (options.data.dialog_text); text = gtk_label_new (NULL); if (!options.data.no_markup) gtk_label_set_markup (GTK_LABEL (text), buf); else gtk_label_set_text (GTK_LABEL (text), buf); g_free (buf); gtk_widget_set_name (text, "yad-dialog-label"); gtk_label_set_line_wrap (GTK_LABEL (text), TRUE); gtk_label_set_selectable (GTK_LABEL (text), options.data.selectable_labels); gtk_label_set_justify (GTK_LABEL (text), options.data.text_align); switch (options.data.text_align) { case GTK_JUSTIFY_LEFT: case GTK_JUSTIFY_FILL: gtk_misc_set_alignment (GTK_MISC (text), 0.0, 0.5); break; case GTK_JUSTIFY_CENTER: gtk_misc_set_alignment (GTK_MISC (text), 0.5, 0.5); break; case GTK_JUSTIFY_RIGHT: gtk_misc_set_alignment (GTK_MISC (text), 1.0, 0.5); break; } if (options.data.image_on_top) gtk_box_pack_start (GTK_BOX (hbox2), text, TRUE, TRUE, 2); else gtk_box_pack_start (GTK_BOX (vbox), text, FALSE, FALSE, 2); #if !GTK_CHECK_VERSION(3,0,0) if (!options.data.fixed) g_signal_connect (G_OBJECT (text), "size-allocate", G_CALLBACK (text_size_allocate_cb), NULL); #endif } } /* add main widget */ switch (options.mode) { case YAD_MODE_CALENDAR: main_widget = calendar_create_widget (dlg); break; case YAD_MODE_COLOR: main_widget = color_create_widget (dlg); break; case YAD_MODE_DND: dnd_init (dlg); break; case YAD_MODE_ENTRY: main_widget = entry_create_widget (dlg); break; case YAD_MODE_FILE: main_widget = file_create_widget (dlg); break; case YAD_MODE_FONT: main_widget = font_create_widget (dlg); break; case YAD_MODE_FORM: main_widget = form_create_widget (dlg); break; #ifdef HAVE_HTML case YAD_MODE_HTML: main_widget = html_create_widget (dlg); break; #endif case YAD_MODE_ICONS: main_widget = icons_create_widget (dlg); break; case YAD_MODE_LIST: main_widget = list_create_widget (dlg); break; case YAD_MODE_MULTI_PROGRESS: main_widget = multi_progress_create_widget (dlg); break; case YAD_MODE_NOTEBOOK: main_widget = notebook_create_widget (dlg); break; case YAD_MODE_PANED: main_widget = paned_create_widget (dlg); break; case YAD_MODE_PROGRESS: main_widget = progress_create_widget (dlg); break; case YAD_MODE_SCALE: main_widget = scale_create_widget (dlg); break; case YAD_MODE_TEXTINFO: main_widget = text_create_widget (dlg); break; default: ; } if (main_widget) { if (options.data.expander) { GtkWidget *exp; exp = gtk_expander_new_with_mnemonic (options.data.expander); gtk_expander_set_expanded (GTK_EXPANDER (exp), FALSE); gtk_container_add (GTK_CONTAINER (exp), main_widget); gtk_box_pack_start (GTK_BOX (vbox), exp, TRUE, TRUE, 2); } else gtk_box_pack_start (GTK_BOX (vbox), main_widget, TRUE, TRUE, 2); } /* add buttons */ if (!options.data.no_buttons) { if (options.data.buttons) { GSList *tmp = options.data.buttons; do { GtkWidget *btn; YadButton *b = (YadButton *) tmp->data; btn = gtk_button_new (); gtk_container_add (GTK_CONTAINER (btn), get_label (b->name, 2)); gtk_button_set_alignment (GTK_BUTTON (btn), 0.5, 0.5); g_object_set_data (G_OBJECT (btn), "resp", GINT_TO_POINTER (b->response)); g_signal_connect (G_OBJECT (btn), "clicked", G_CALLBACK (btn_cb), b->cmd); gtk_box_pack_start (GTK_BOX (bbox), btn, FALSE, FALSE, 0); tmp = tmp->next; } while (tmp != NULL); } else { if (options.mode == YAD_MODE_PROGRESS || options.mode == YAD_MODE_MULTI_PROGRESS) gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_CLOSE, YAD_RESPONSE_OK, NULL); else { if (gtk_alternative_dialog_button_order (NULL)) gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_OK, YAD_RESPONSE_OK, GTK_STOCK_CANCEL, YAD_RESPONSE_CANCEL, NULL); else gtk_dialog_add_buttons (GTK_DIALOG (dlg), GTK_STOCK_CANCEL, YAD_RESPONSE_CANCEL, GTK_STOCK_OK, YAD_RESPONSE_OK, NULL); } gtk_dialog_set_default_response (GTK_DIALOG (dlg), YAD_RESPONSE_OK); } gtk_button_box_set_layout (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dlg))), options.data.buttons_layout); } /* show widgets */ gtk_widget_show_all (gtk_dialog_get_content_area (GTK_DIALOG (dlg))); if (options.data.no_buttons) gtk_widget_hide (bbox); /* parse geometry, if given. must be after showing widget */ if (options.data.geometry && !options.data.maximized && !options.data.fullscreen) { gtk_widget_realize (dlg); gtk_window_parse_geometry (GTK_WINDOW (dlg), options.data.geometry); } gtk_widget_show (dlg); /* set maximized or fixed size after showing widget */ if (options.data.maximized) gtk_window_maximize (GTK_WINDOW (dlg)); else if (options.data.fullscreen) gtk_window_fullscreen (GTK_WINDOW (dlg)); else { gtk_window_set_resizable (GTK_WINDOW (dlg), !options.data.fixed); if (options.data.fixed) gtk_widget_set_size_request (dlg, options.data.width, options.data.height); } /* set timeout */ if (options.data.timeout) { g_timeout_add_seconds (options.data.timeout, timeout_cb, dlg); g_timeout_add_seconds (1, timeout_indicator_cb, topb); } #ifndef G_OS_WIN32 /* print xid */ if (options.print_xid) { fprintf (stderr, "0x%lX", GDK_WINDOW_XID (gtk_widget_get_window (dlg))); fflush (stderr); } #endif return dlg; }
bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = TRUE; m_acceptsFocus = TRUE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxButton creation failed") ); return FALSE; } /* wxString label2( label ); for (size_t i = 0; i < label2.Len(); i++) { if (label2.GetChar(i) == wxT('&')) label2.SetChar(i,wxT('_')); } GtkWidget *accel_label = gtk_accel_label_new( label2.mb_str() ); gtk_widget_show( accel_label ); m_widget = gtk_button_new(); gtk_container_add( GTK_CONTAINER(m_widget), accel_label ); gtk_accel_label_set_accel_widget( GTK_ACCEL_LABEL(accel_label), m_widget ); guint accel_key = gtk_label_parse_uline (GTK_LABEL(accel_label), label2.mb_str() ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(accel_label) ); wxControl::SetLabel( label ); */ #ifdef __WXGTK20__ m_widget = gtk_button_new_with_mnemonic(""); #else m_widget = gtk_button_new_with_label(""); #endif float x_alignment = 0.5; if (HasFlag(wxBU_LEFT)) x_alignment = 0.0; else if (HasFlag(wxBU_RIGHT)) x_alignment = 1.0; float y_alignment = 0.5; if (HasFlag(wxBU_TOP)) y_alignment = 0.0; else if (HasFlag(wxBU_BOTTOM)) y_alignment = 1.0; #if __WXGTK24__ if (!gtk_check_version(2,4,0)) { gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment); } else #endif { if (GTK_IS_MISC(BUTTON_CHILD(m_widget))) gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)), x_alignment, y_alignment); } SetLabel(label); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); gtk_signal_connect_after( GTK_OBJECT(m_widget), "style_set", GTK_SIGNAL_FUNC(gtk_button_style_set_callback), (gpointer*) this ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
static void brasero_project_type_chooser_build_recent (BraseroProjectTypeChooser *self, GtkRecentManager *recent) { GtkSizeGroup *image_group; GtkSizeGroup *group; GList *list = NULL; gchar *filename; GList *recents; GList *iter; recents = gtk_recent_manager_get_items (recent); for (iter = recents; iter; iter = iter->next) { GtkRecentInfo *info; const gchar *mime; info = iter->data; mime = gtk_recent_info_get_mime_type (info); if (!mime) continue; /* filter those we want */ if (strcmp (mime, "application/x-brasero") && strcmp (mime, "application/x-cd-image") && strcmp (mime, "application/x-cdrdao-toc") && strcmp (mime, "application/x-toc") && strcmp (mime, "application/x-cue") && strcmp (mime, "audio/x-scpls") && strcmp (mime, "audio/x-ms-asx") && strcmp (mime, "audio/x-mp3-playlist") && strcmp (mime, "audio/x-mpegurl")) continue; /* sort */ list = g_list_insert_sorted (list, info, brasero_project_type_chooser_sort_recent); if (g_list_length (list) > 5) list = g_list_delete_link (list, g_list_last (list)); } group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); image_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH); /* If a project was left unfinished last time then add another entry */ filename = g_build_filename (g_get_user_config_dir (), "brasero", BRASERO_SESSION_TMP_PROJECT_PATH, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { gchar *uri; GtkWidget *link; GtkWidget *image; uri = g_filename_to_uri (filename, NULL, NULL); image = gtk_image_new_from_icon_name ("brasero", GTK_ICON_SIZE_BUTTON); gtk_size_group_add_widget (image_group, image); link = gtk_button_new_with_label (_("Last _Unsaved Project")); g_object_set_data_full (G_OBJECT (link), "BraseroButtonURI", uri, g_free); gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE); gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5); gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE); gtk_button_set_image (GTK_BUTTON (link), image); gtk_button_set_use_underline (GTK_BUTTON (link), TRUE); g_signal_connect (link, "clicked", G_CALLBACK (brasero_project_type_chooser_last_unsaved_clicked_cb), self); gtk_widget_show (link); gtk_widget_set_tooltip_text (link, _("Load the last project that was not burned and not saved")); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0); gtk_size_group_add_widget (group, link); } g_free (filename); for (iter = list; iter; iter = iter->next) { GtkRecentInfo *info; GList *child_iter; const gchar *name; GIcon *icon; GtkWidget *image; const gchar *uri; GtkWidget *child; GtkWidget *link; GList *children; gchar *tooltip; info = iter->data; tooltip = gtk_recent_info_get_uri_display (info); icon = gtk_recent_info_get_gicon (info); image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON); g_object_unref (icon); gtk_size_group_add_widget (image_group, image); gtk_widget_show (image); gtk_widget_set_tooltip_text (image, tooltip); name = gtk_recent_info_get_display_name (info); uri = gtk_recent_info_get_uri (info); /* Don't use mnemonics with filenames */ link = gtk_button_new_with_label (name); g_object_set_data_full (G_OBJECT (link), "BraseroButtonURI", g_strdup (uri), g_free); gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE); gtk_button_set_image (GTK_BUTTON (link), image); gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5); gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE); g_signal_connect (link, "clicked", G_CALLBACK (brasero_project_type_chooser_recent_clicked_cb), self); gtk_widget_show (link); gtk_widget_set_tooltip_text (link, tooltip); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0); g_free (tooltip); gtk_size_group_add_widget (group, link); /* That's a tedious hack to avoid mnemonics which are hardcoded * when you add an image to a button. BUG? */ if (!GTK_IS_BIN (link)) continue; child = gtk_bin_get_child (GTK_BIN (link)); if (!GTK_IS_ALIGNMENT (child)) continue; gtk_alignment_set (GTK_ALIGNMENT (child), 0.0, 0.5, 1.0, 1.0); child = gtk_bin_get_child (GTK_BIN (child)); if (!GTK_IS_BOX (child)) continue; children = gtk_container_get_children (GTK_CONTAINER (child)); for (child_iter = children; child_iter; child_iter = child_iter->next) { GtkWidget *widget; widget = child_iter->data; if (GTK_IS_LABEL (widget)) { gtk_label_set_use_underline (GTK_LABEL (widget), FALSE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); /* Make sure that the name is not too long */ gtk_box_set_child_packing (GTK_BOX (child), widget, TRUE, TRUE, 0, GTK_PACK_START); gtk_label_set_ellipsize (GTK_LABEL (widget), PANGO_ELLIPSIZE_END); break; } } g_list_free (children); } g_object_unref (image_group); g_object_unref (group); if (!g_list_length (list)) { GtkWidget *label; gchar *string; string = g_strdup_printf ("<i>%s</i>", _("No recently used project")); label = gtk_label_new (string); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); g_free (string); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (self->priv->recent_box), label, FALSE, FALSE, 0); } g_list_free (list); g_list_foreach (recents, (GFunc) gtk_recent_info_unref, NULL); g_list_free (recents); }
static void dialog_init (SortFlowState *state) { GtkTable *table; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkCellRenderer *renderer; gboolean col_rb; GnmRange const *range; table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_options_table")); /* setup range entry */ state->range_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->range_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->range_entry), 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->range_entry)); gnm_expr_entry_set_update_policy (state->range_entry, GTK_UPDATE_DISCONTINUOUS); gtk_widget_show (GTK_WIDGET (state->range_entry)); g_signal_connect_swapped (G_OBJECT (state->range_entry), "changed", G_CALLBACK (cb_update_to_new_range), state); state->locale_selector = GO_LOCALE_SEL (go_locale_sel_new ()); gtk_widget_show_all (GTK_WIDGET (state->locale_selector)); gtk_table_attach (table, GTK_WIDGET (state->locale_selector), 2, 3, 5, 6, GTK_EXPAND | GTK_FILL, 0, 0, 0); table = GTK_TABLE (go_gtk_builder_get_widget (state->gui, "cell_sort_spec_table")); /* setup add entry */ state->add_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->add_entry, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_table_attach (table, GTK_WIDGET (state->add_entry), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->add_entry)); gtk_widget_show (GTK_WIDGET (state->add_entry)); /* Set-up tree view */ scrolled = go_gtk_builder_get_widget (state->gui, "scrolled_cell_sort_list"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_INT); state->treeview = GTK_TREE_VIEW ( gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); state->selection = gtk_tree_view_get_selection (state->treeview); gtk_tree_selection_set_mode (state->selection, GTK_SELECTION_BROWSE); g_signal_connect_swapped (state->selection, "changed", G_CALLBACK (cb_sort_selection_changed), state); state->header_column = gtk_tree_view_column_new_with_attributes (_("Header"), gtk_cell_renderer_text_new (), "text", ITEM_HEADER, NULL); gtk_tree_view_append_column (state->treeview, state->header_column); column = gtk_tree_view_column_new_with_attributes (_("Row/Column"), gtk_cell_renderer_text_new (), "text", ITEM_NAME, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gnumeric_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_descending), state); column = gtk_tree_view_column_new_with_attributes ("", renderer, "active", ITEM_DESCENDING, "pixbuf", ITEM_DESCENDING_IMAGE, NULL); gtk_tree_view_append_column (state->treeview, column); renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_case_sensitive), state); column = gtk_tree_view_column_new_with_attributes (_("Case Sensitive"), renderer, "active", ITEM_CASE_SENSITIVE, NULL); gtk_tree_view_append_column (state->treeview, column); gtk_tree_view_columns_autosize (state->treeview); g_signal_connect (G_OBJECT (state->treeview), "key_press_event", G_CALLBACK (cb_treeview_keypress), state); g_signal_connect (G_OBJECT (state->treeview), "button_press_event", G_CALLBACK (cb_treeview_button_press), state); #if 0 /* We are currently not supporting `by-value' vs not. */ renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (cb_toggled_sort_by_value), state); column = gtk_tree_view_column_new_with_attributes (_("By Value"), renderer, "active", ITEM_SORT_BY_VALUE, NULL); gtk_tree_view_append_column (state->treeview, column); #endif gtk_tree_view_set_reorderable (state->treeview,TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->treeview)); gtk_widget_show (GTK_WIDGET (state->treeview)); /* Set-up other widgets */ state->cell_sort_row_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_row_rb"); state->cell_sort_col_rb = go_gtk_builder_get_widget (state->gui, "cell_sort_col_rb"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_row_rb), "toggled", G_CALLBACK (cb_update_to_new_range), state); state->cell_sort_header_check = go_gtk_builder_get_widget (state->gui, "cell_sort_header_check"); g_signal_connect_swapped (G_OBJECT (state->cell_sort_header_check), "toggled", G_CALLBACK (cb_sort_header_check), state); state->retain_format_check = go_gtk_builder_get_widget (state->gui, "retain_format_button"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->retain_format_check), gnm_conf_get_core_sort_default_retain_formats ()); /* Set-up buttons */ state->up_button = go_gtk_builder_get_widget (state->gui, "up_button"); g_signal_connect_swapped (G_OBJECT (state->up_button), "clicked", G_CALLBACK (cb_up), state); state->down_button = go_gtk_builder_get_widget (state->gui, "down_button"); g_signal_connect_swapped (G_OBJECT (state->down_button), "clicked", G_CALLBACK (cb_down), state); state->add_button = go_gtk_builder_get_widget (state->gui, "add_button"); g_signal_connect_swapped (G_OBJECT (state->add_button), "clicked", G_CALLBACK (cb_add_clicked), state); gtk_widget_set_sensitive (state->add_button, TRUE); state->delete_button = go_gtk_builder_get_widget (state->gui, "delete_button"); g_signal_connect (G_OBJECT (state->delete_button), "clicked", G_CALLBACK (cb_delete_clicked), state); gtk_widget_set_sensitive (state->delete_button, FALSE); state->clear_button = go_gtk_builder_get_widget (state->gui, "clear_button"); g_signal_connect_swapped (G_OBJECT (state->clear_button), "clicked", G_CALLBACK (cb_clear_clicked), state); gtk_widget_set_sensitive (state->clear_button, FALSE); gtk_button_set_alignment (GTK_BUTTON (state->up_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->down_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->add_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_button), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->clear_button), 0., .5); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_CELL_SORT); state->ok_button = go_gtk_builder_get_widget (state->gui, "ok_button"); g_signal_connect_swapped (G_OBJECT (state->ok_button), "clicked", G_CALLBACK (cb_dialog_ok_clicked), state); state->cancel_button = go_gtk_builder_get_widget (state->gui, "cancel_button"); g_signal_connect (G_OBJECT (state->cancel_button), "clicked", G_CALLBACK (cb_dialog_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); /* Finish dialog signals */ wbc_gtk_attach_guru (state->wbcg, state->dialog); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_dialog_destroy); range = dialog_load_selection (state, &col_rb); cb_sort_selection_changed (state); gnm_expr_entry_grab_focus(GNM_EXPR_ENTRY (state->add_entry), TRUE); }
/** * dialog_init: * @state: * * Create the dialog (guru). * **/ static gboolean dialog_init (SolverState *state) { GtkGrid *grid; GnmSolverParameters *param; GtkCellRenderer *renderer; GtkListStore *store; GtkTreeViewColumn *column; GSList *cl; GnmCell *target_cell; GnmValue const *input; int i; param = state->sheet->solver_parameters; state->gui = gnm_gtk_builder_load ("solver.ui", NULL, GO_CMD_CONTEXT (state->wbcg)); if (state->gui == NULL) return TRUE; state->dialog = go_gtk_builder_get_widget (state->gui, "Solver"); if (state->dialog == NULL) return TRUE; state->notebook = go_gtk_builder_get_widget (state->gui, "solver_notebook"); /* buttons */ state->solve_button = go_gtk_builder_get_widget (state->gui, "solvebutton"); g_signal_connect (G_OBJECT (state->solve_button), "clicked", G_CALLBACK (cb_dialog_solve_clicked), state); state->close_button = go_gtk_builder_get_widget (state->gui, "closebutton"); g_signal_connect (G_OBJECT (state->close_button), "clicked", G_CALLBACK (cb_dialog_close_clicked), state); state->help_button = go_gtk_builder_get_widget (state->gui, "helpbutton"); gnm_init_help_button (state->help_button, GNUMERIC_HELP_LINK_SOLVER); state->add_button = go_gtk_builder_get_widget (state->gui, "addbutton"); gtk_button_set_alignment (GTK_BUTTON (state->add_button), 0.5, .5); g_signal_connect_swapped (G_OBJECT (state->add_button), "clicked", G_CALLBACK (cb_dialog_add_clicked), state); state->change_button = go_gtk_builder_get_widget (state->gui, "changebutton"); g_signal_connect (G_OBJECT (state->change_button), "clicked", G_CALLBACK (cb_dialog_change_clicked), state); state->delete_button = go_gtk_builder_get_widget (state->gui, "deletebutton"); gtk_button_set_alignment (GTK_BUTTON (state->delete_button), 0.5, .5); g_signal_connect (G_OBJECT (state->delete_button), "clicked", G_CALLBACK (cb_dialog_delete_clicked), state); state->stop_button = go_gtk_builder_get_widget (state->gui, "stopbutton"); g_signal_connect_swapped (G_OBJECT (state->stop_button), "clicked", G_CALLBACK (cb_stop_solver), state); /* target_entry */ grid = GTK_GRID (go_gtk_builder_get_widget (state->gui, "parameter-grid")); state->target_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->target_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->target_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->target_entry), 1, 0, 2, 1); gnm_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->target_entry)); gtk_widget_show (GTK_WIDGET (state->target_entry)); g_signal_connect_after (G_OBJECT (state->target_entry), "changed", G_CALLBACK (dialog_set_main_button_sensitivity), state); /* change_cell_entry */ state->change_cell_entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->change_cell_entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->change_cell_entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->change_cell_entry), 1, 2, 2, 1); gnm_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->change_cell_entry)); gtk_widget_show (GTK_WIDGET (state->change_cell_entry)); g_signal_connect_after (G_OBJECT (state->change_cell_entry), "changed", G_CALLBACK (dialog_set_main_button_sensitivity), state); /* Algorithm */ state->algorithm_combo = GTK_COMBO_BOX (go_gtk_builder_get_widget (state->gui, "algorithm_combo")); renderer = (GtkCellRenderer*) gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (state->algorithm_combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (state->algorithm_combo), renderer, "text", 0, NULL); fill_algorithm_combo (state, param->options.model_type); for (i = 0; model_type_group[i]; i++) { const char *bname = model_type_group[i]; GtkWidget *w = go_gtk_builder_get_widget(state->gui, bname); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), param->options.model_type == (GnmSolverModelType)i); g_signal_connect (G_OBJECT (w), "clicked", G_CALLBACK (cb_dialog_model_type_clicked), state); } /* Options */ state->max_iter_entry = go_gtk_builder_get_widget (state->gui, "max_iter_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->max_iter_entry), param->options.max_iter); state->max_time_entry = go_gtk_builder_get_widget (state->gui, "max_time_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->max_time_entry), param->options.max_time_sec); state->gradient_order_entry = go_gtk_builder_get_widget (state->gui, "gradient_order_entry"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->gradient_order_entry), param->options.gradient_order); /* lhs_entry */ grid = GTK_GRID (go_gtk_builder_get_widget (state->gui, "constraints-grid")); state->lhs.entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->lhs.entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->lhs.entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->lhs.entry), 0, 4, 1, 1); state->lhs.label = go_gtk_builder_get_widget (state->gui, "lhs_label"); gtk_label_set_mnemonic_widget (GTK_LABEL (state->lhs.label), GTK_WIDGET (state->lhs.entry)); gtk_widget_show (GTK_WIDGET (state->lhs.entry)); g_signal_connect_after (G_OBJECT (state->lhs.entry), "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); g_signal_connect_swapped ( gnm_expr_entry_get_entry (GNM_EXPR_ENTRY (state->lhs.entry)), "activate", G_CALLBACK (cb_dialog_add_clicked), state); /* rhs_entry */ state->rhs.entry = gnm_expr_entry_new (state->wbcg, TRUE); gnm_expr_entry_set_flags (state->rhs.entry, GNM_EE_SINGLE_RANGE | GNM_EE_FORCE_ABS_REF | GNM_EE_SHEET_OPTIONAL | GNM_EE_CONSTANT_ALLOWED, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->rhs.entry), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->rhs.entry), 2, 4, 1, 1); gtk_widget_show (GTK_WIDGET (state->rhs.entry)); state->rhs.label = go_gtk_builder_get_widget (state->gui, "rhs_label"); gtk_label_set_mnemonic_widget ( GTK_LABEL (state->rhs.label), GTK_WIDGET (state->rhs.entry)); g_signal_connect_after (G_OBJECT (state->rhs.entry), "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); g_signal_connect_swapped ( gnm_expr_entry_get_entry (GNM_EXPR_ENTRY (state->rhs.entry)), "activate", G_CALLBACK (cb_dialog_add_clicked), state); /* type_menu */ state->type_combo = GTK_COMBO_BOX (go_gtk_builder_get_widget (state->gui, "type_menu")); gtk_combo_box_set_active (state->type_combo, 0); g_signal_connect (state->type_combo, "changed", G_CALLBACK (dialog_set_sec_button_sensitivity), state); /* constraint_list */ state->constraint_list = GTK_TREE_VIEW (go_gtk_builder_get_widget (state->gui, "constraint_list")); state->constr = NULL; g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (state->constraint_list)), "changed", G_CALLBACK (constraint_select_click), state); gtk_tree_view_set_reorderable (state->constraint_list, TRUE); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); gtk_tree_view_set_model (state->constraint_list, GTK_TREE_MODEL(store)); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ( _("Subject to the Constraints:"), renderer, "text", 0, NULL); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_append_column (state->constraint_list, column); { GtkWidget *w = GTK_WIDGET (state->constraint_list); int width, height, vsep; PangoLayout *layout = gtk_widget_create_pango_layout (w, "Mg19"); gtk_widget_style_get (w, "vertical_separator", &vsep, NULL); pango_layout_get_pixel_size (layout, &width, &height); gtk_widget_set_size_request (w, -1, (2 * height + vsep) * (4 + 1)); g_object_unref (layout); } /* Loading the old solver specs... from param */ for (cl = param->constraints; cl; cl = cl->next) { GnmSolverConstraint const *c = cl->data; GtkTreeIter iter; char *str; gtk_list_store_append (store, &iter); str = gnm_solver_constraint_as_str (c, state->sheet); gtk_list_store_set (store, &iter, 0, str, 1, c, -1); g_free (str); } g_object_unref (store); INIT_BOOL_ENTRY ("autoscale_button", options.automatic_scaling); INIT_BOOL_ENTRY ("non_neg_button", options.assume_non_negative); INIT_BOOL_ENTRY ("all_int_button", options.assume_discrete); INIT_BOOL_ENTRY ("program", options.program_report); INIT_BOOL_ENTRY ("sensitivity", options.sensitivity_report); input = gnm_solver_param_get_input (param); if (input != NULL) gnm_expr_entry_load_from_text (state->change_cell_entry, value_peek_string (input)); target_cell = gnm_solver_param_get_target_cell (param); if (target_cell) gnm_expr_entry_load_from_text (state->target_entry, cell_name (target_cell)); else { SheetView *sv = wb_control_cur_sheet_view (GNM_WBC (state->wbcg)); if (sv) { GnmRange first = {sv->edit_pos, sv->edit_pos}; gnm_expr_entry_load_from_range (state->target_entry, state->sheet, &first); } } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "max_button")), param->problem_type == GNM_SOLVER_MAXIMIZE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "min_button")), param->problem_type == GNM_SOLVER_MINIMIZE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "no_scenario")), ! param->options.add_scenario); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON ( go_gtk_builder_get_widget(state->gui, "optimal_scenario")), param->options.add_scenario); state->scenario_name_entry = go_gtk_builder_get_widget (state->gui, "scenario_name_entry"); gtk_entry_set_text (GTK_ENTRY (state->scenario_name_entry), param->options.scenario_name); state->run.status_widget = go_gtk_builder_get_widget (state->gui, "solver_status_label"); state->run.problem_status_widget = go_gtk_builder_get_widget (state->gui, "problem_status_label"); state->run.objective_value_widget = go_gtk_builder_get_widget (state->gui, "objective_value_label"); state->run.timer_widget = go_gtk_builder_get_widget (state->gui, "elapsed_time_label"); state->run.spinner = go_gtk_builder_get_widget (state->gui, "run_spinner"); /* Done */ gnm_expr_entry_grab_focus (state->target_entry, FALSE); wbcg_set_entry (state->wbcg, state->target_entry); dialog_set_main_button_sensitivity (NULL, state); dialog_set_sec_button_sensitivity (NULL, state); /* dialog */ wbc_gtk_attach_guru (state->wbcg, state->dialog); g_signal_connect_swapped (G_OBJECT (state->dialog), "destroy", G_CALLBACK (cb_dialog_solver_destroy), state); g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify)unref_state); return FALSE; }
/** update the device list */ void _lib_import_ui_devices_update(dt_lib_module_t *self) { dt_lib_import_t *d = (dt_lib_import_t*)self->data; GList *citem; /* cleanup of widgets in devices container*/ GList *item; if((item=gtk_container_get_children(GTK_CONTAINER(d->devices)))!=NULL) do { gtk_container_remove(GTK_CONTAINER(d->devices),GTK_WIDGET(item->data)); } while((item=g_list_next(item))!=NULL); /* add the rescan button */ GtkButton *scan = GTK_BUTTON(gtk_button_new_with_label(_("scan for devices"))); d->scan_devices = scan; gtk_button_set_alignment(scan, 0.05, 0.5); g_object_set(G_OBJECT(scan), "tooltip-text", _("scan for newly attached devices"), (char *)NULL); g_signal_connect (G_OBJECT(scan), "clicked",G_CALLBACK (_lib_import_scan_devices_callback), self); gtk_box_pack_start(GTK_BOX(d->devices),GTK_WIDGET(scan),TRUE,TRUE,0); gtk_box_pack_start(GTK_BOX(d->devices),GTK_WIDGET(gtk_label_new("")),TRUE,TRUE,0); uint32_t count=0; /* FIXME: Verify that it's safe to access camctl->cameras list here ? */ if( (citem = g_list_first (darktable.camctl->cameras))!=NULL) { // Add detected supported devices char buffer[512]= {0}; do { dt_camera_t *camera=(dt_camera_t *)citem->data; count++; /* add camera label */ GtkWidget *label = GTK_WIDGET (dtgtk_label_new (camera->model,DARKTABLE_LABEL_TAB|DARKTABLE_LABEL_ALIGN_LEFT)); gtk_box_pack_start (GTK_BOX (d->devices),label,TRUE,TRUE,0); /* set camera summary if available */ if( camera->summary.text !=NULL && strlen(camera->summary.text) >0 ) { g_object_set(G_OBJECT(label), "tooltip-text", camera->summary.text, (char *)NULL); } else { sprintf(buffer,_("device \"%s\" connected on port \"%s\"."),camera->model,camera->port); g_object_set(G_OBJECT(label), "tooltip-text", buffer, (char *)NULL); } /* add camera actions buttons */ GtkWidget *ib=NULL,*tb=NULL; GtkWidget *vbx=gtk_vbox_new(FALSE,5); if( camera->can_import==TRUE ) { gtk_box_pack_start (GTK_BOX (vbx),(ib=gtk_button_new_with_label (_("import from camera"))),FALSE,FALSE,0); d->import_camera = GTK_BUTTON(ib); } if( camera->can_tether==TRUE ) { gtk_box_pack_start (GTK_BOX (vbx),(tb=gtk_button_new_with_label (_("tethered shoot"))),FALSE,FALSE,0); d->tethered_shoot = GTK_BUTTON(tb); } if( ib ) { g_signal_connect (G_OBJECT (ib), "clicked",G_CALLBACK (_lib_import_from_camera_callback), camera); gtk_button_set_alignment(GTK_BUTTON(ib), 0.05, 0.5); } if( tb ) { g_signal_connect (G_OBJECT (tb), "clicked",G_CALLBACK (_lib_import_tethered_callback), camera); gtk_button_set_alignment(GTK_BUTTON(tb), 0.05, 0.5); } gtk_box_pack_start (GTK_BOX (d->devices),vbx,FALSE,FALSE,0); } while ((citem=g_list_next (citem))!=NULL); } if( count == 0 ) { // No supported devices is detected lets notice user.. gtk_box_pack_start(GTK_BOX(d->devices),gtk_label_new(_("no supported devices found")),TRUE,TRUE,0); } gtk_widget_show_all(GTK_WIDGET(d->devices)); }
static VALUE button_set_alignment(VALUE self, VALUE xalign, VALUE yalign) { gtk_button_set_alignment(_SELF(self), NUM2DBL(xalign), NUM2DBL(yalign)); return self; }
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxButton creation failed") ); return false; } // create either a standard button with text label (which may still contain // an image under GTK+ 2.6+) or a bitmap-only button if we don't have any // label const bool useLabel = !(style & wxBU_NOTEXT) && (!label.empty() || wxIsStockID(id)); if ( useLabel ) { m_widget = gtk_button_new_with_mnemonic(""); } else // no label, suppose we will have a bitmap { m_widget = gtk_button_new(); GtkWidget *image = gtk_image_new(); gtk_widget_show(image); gtk_container_add(GTK_CONTAINER(m_widget), image); } g_object_ref(m_widget); float x_alignment = 0.5; if (HasFlag(wxBU_LEFT)) x_alignment = 0.0; else if (HasFlag(wxBU_RIGHT)) x_alignment = 1.0; float y_alignment = 0.5; if (HasFlag(wxBU_TOP)) y_alignment = 0.0; else if (HasFlag(wxBU_BOTTOM)) y_alignment = 1.0; gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment); if ( useLabel ) SetLabel(label); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); g_signal_connect_after (m_widget, "clicked", G_CALLBACK (wxgtk_button_clicked_callback), this); g_signal_connect_after (m_widget, "style_set", G_CALLBACK (wxgtk_button_style_set_callback), this); m_parent->DoAddChild( this ); PostCreation(size); return true; }
/* public functions */ GtkWidget * asgtk_gradient_new () { ASGtkGradient *ge; GtkWidget *main_vbox, *main_hbox; GtkWidget *scrolled_window ; GtkWidget *list_vbox ; GtkWidget *frame, *hbox, *vbox, *btn, *table; GtkWidget *label ; ge = g_object_new (ASGTK_TYPE_GRADIENT, NULL); colorize_gtk_window( GTK_WIDGET(ge) ); gtk_container_set_border_width( GTK_CONTAINER (ge), 5 ); main_vbox = GTK_DIALOG(ge)->vbox ; main_hbox = gtk_hbox_new (FALSE, 5); gtk_widget_show (main_hbox); gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0); list_vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_hbox), list_vbox, FALSE, FALSE, 0); frame = gtk_frame_new("Gradient direction : "); gtk_box_pack_start (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); table = gtk_table_new( 2, 2, FALSE ); gtk_container_add (GTK_CONTAINER (frame), table); gtk_container_set_border_width (GTK_CONTAINER (table), 3); ge->l2r_radio = gtk_radio_button_new_with_label( NULL, "Left to Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->l2r_radio, 0, 1, 0, 1); ge->t2b_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->l2r_radio), "Top to Bottom" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->t2b_radio, 0, 1, 1, 2); ge->tl2br_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->t2b_radio), "Top-Left to Bottom-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->tl2br_radio, 1, 2, 0, 1); ge->bl2tr_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->tl2br_radio), "Bottom-Left to Top-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->bl2tr_radio, 1, 2, 1, 2); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( frame, get_colorschemed_style_normal() ); g_signal_connect ((gpointer) ge->l2r_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->tl2br_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->t2b_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->bl2tr_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); ge->screen_width_check = gtk_check_button_new_with_label("Use screen width"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_width_check), TRUE ); ge->width_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->width_entry, FALSE ); ge->screen_height_check = gtk_check_button_new_with_label("Use screen height"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_height_check), TRUE ); ge->height_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->height_entry, FALSE ); g_signal_connect ((gpointer) ge->screen_width_check, "clicked", G_CALLBACK (on_size_clicked), ge); g_signal_connect ((gpointer) ge->screen_height_check, "clicked", G_CALLBACK (on_size_clicked), ge); ge->size_frame = gtk_frame_new("Rendered gradient size : "); gtk_box_pack_start (GTK_BOX (list_vbox), ge->size_frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(ge->size_frame) ); table = gtk_table_new( 2, 4, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); gtk_container_add( GTK_CONTAINER(ge->size_frame), table ); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Width : "), 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->width_entry, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Height : "), 2, 3, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->height_entry, 3, 4, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->screen_width_check, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_table_attach (GTK_TABLE (table), ge->screen_height_check, 2, 4, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( ge->size_frame, get_colorschemed_style_normal() ); scrolled_window = asgtk_gradient_create_color_list( ge ); gtk_box_pack_start (GTK_BOX (list_vbox), scrolled_window, FALSE, FALSE, 0); ge->color_entry = gtk_entry_new_with_max_length(24); gtk_entry_set_width_chars( GTK_ENTRY(ge->color_entry), 16 ); #if 0 ge->color_preview = gtk_color_button_new(); g_signal_connect ((gpointer) ge->color_preview, "clicked", G_CALLBACK (on_color_preview_clicked), ge); #else ge->color_preview = gtk_image_new(); update_color_preview( ge, DEFAULT_COLOR_STR ); #endif ge->offset_entry = gtk_spin_button_new_with_range( 0., 1., 0.05 ); frame = gtk_frame_new("Change point attributes : "); gtk_box_pack_end (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_container_add( GTK_CONTAINER(frame), vbox ); table = gtk_table_new( 4, 2, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); // hbox = gtk_hbox_new( FALSE, 5 ); // gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); label = gtk_label_new("Color : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); label = gtk_label_new("Offset : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->color_entry, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); gtk_table_attach (GTK_TABLE (table), ge->offset_entry, 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); frame = gtk_frame_new(NULL); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); gtk_widget_set_size_request( frame, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT ); gtk_container_set_border_width( GTK_CONTAINER (table), 0 ); gtk_container_add( GTK_CONTAINER(frame), ge->color_preview ); gtk_widget_show( ge->color_preview ); btn = gtk_button_new(); gtk_container_set_border_width( GTK_CONTAINER (btn), 0 ); //btn = gtk_button_new_with_label(" Color selector "); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_container_add (GTK_CONTAINER (btn), frame); gtk_widget_show (frame); g_signal_connect ((gpointer) frame, "size-allocate", G_CALLBACK (color_preview_size_alloc), ge); gtk_table_attach (GTK_TABLE (table), btn, 0, 2, 1, 2, GTK_FILL, GTK_SHRINK, 2, 2); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_color_clicked), ge); gtk_widget_show_all (table); gtk_widget_show (table); hbox = gtk_hbox_new( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); ge->delete_btn = btn = gtk_button_new_from_stock(GTK_STOCK_DELETE); gtk_widget_set_sensitive( ge->delete_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_delete_point_clicked), ge); btn = gtk_button_new_from_stock(GTK_STOCK_ADD); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_add_point_clicked), ge); ge->apply_btn = btn = gtk_button_new_from_stock(GTK_STOCK_APPLY); gtk_widget_set_sensitive( ge->apply_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_apply_point_clicked), ge); gtk_widget_show_all (hbox); gtk_widget_show (hbox); /* The preview : */ ge->image_view = ASGTK_IMAGE_VIEW(asgtk_image_view_new()); gtk_widget_set_size_request (GTK_WIDGET(ge->image_view), PREVIEW_WIDTH, PREVIEW_HEIGHT); gtk_box_pack_end (GTK_BOX (main_hbox), GTK_WIDGET(ge->image_view), TRUE, TRUE, 0); asgtk_image_view_set_aspect ( ge->image_view, get_screen_width(NULL), get_screen_height(NULL) ); asgtk_image_view_set_resize ( ge->image_view, ASGTK_IMAGE_VIEW_SCALE_TO_VIEW| ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, ASGTK_IMAGE_VIEW_RESIZE_ALL ); gtk_widget_show_all (list_vbox); gtk_widget_show_all (main_hbox); gtk_widget_hide(ge->image_view->details_label); btn = gtk_check_button_new_with_label( "Use screen aspect ratio" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_screen_aspect_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = gtk_check_button_new_with_label( "Scale to fit this view" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_scale_to_view_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = asgtk_add_button_to_box( NULL, GTK_STOCK_REFRESH, NULL, G_CALLBACK(on_refresh_clicked), ge ); asgtk_image_view_add_tool( ge->image_view, btn, 3 ); LOCAL_DEBUG_OUT( "created image ASGtkGradient object %p", ge ); return GTK_WIDGET (ge); }
void dialog_merge (WBCGtk *wbcg) { MergeState *state; GtkBuilder *gui; GtkGrid *grid; GtkWidget *scrolled; GtkTreeViewColumn *column; GtkTreeSelection *selection; GnmRange const *r; g_return_if_fail (wbcg != NULL); if (gnumeric_dialog_raise_if_exists (wbcg, MERGE_KEY)) return; gui = gnm_gtk_builder_load ("merge.ui", NULL, GO_CMD_CONTEXT (wbcg)); if (gui == NULL) return; state = g_new0 (MergeState, 1); state->gui = gui; state->wbcg = wbcg; state->sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (state->wbcg)); state->dialog = go_gtk_builder_get_widget (gui, "Merge"); state->warning_dialog = NULL; state->add_btn = go_gtk_builder_get_widget (gui, "add_button"); state->delete_btn = go_gtk_builder_get_widget (gui, "remove_button"); state->merge_btn = go_gtk_builder_get_widget (gui, "merge_button"); state->change_btn = go_gtk_builder_get_widget (gui, "change_button"); state->cancel_btn = go_gtk_builder_get_widget (gui, "cancel_button"); gtk_widget_set_size_request (state->delete_btn, 100, -1); gtk_button_set_alignment (GTK_BUTTON (state->add_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->delete_btn), 0., .5); gtk_button_set_alignment (GTK_BUTTON (state->change_btn), 0., .5); grid = GTK_GRID (go_gtk_builder_get_widget (gui, "main-grid")); state->zone = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->zone, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gnumeric_editable_enters (GTK_WINDOW (state->dialog), GTK_WIDGET (state->zone)); gtk_label_set_mnemonic_widget (GTK_LABEL (go_gtk_builder_get_widget (gui, "var1-label")), GTK_WIDGET (state->zone)); gtk_widget_set_hexpand (GTK_WIDGET (state->zone), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->zone), 1, 0, 2, 1); r = selection_first_range ( wb_control_cur_sheet_view (WORKBOOK_CONTROL (wbcg)), NULL, NULL); if (r != NULL) gnm_expr_entry_load_from_range (state->zone, state->sheet, r); state->data = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->data, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->data), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->data), 0, 5, 1, 1); state->field = gnm_expr_entry_new (wbcg, TRUE); gnm_expr_entry_set_flags (state->field, GNM_EE_SINGLE_RANGE, GNM_EE_MASK); gtk_widget_set_hexpand (GTK_WIDGET (state->field), TRUE); gtk_grid_attach (grid, GTK_WIDGET (state->field), 1, 5, 1, 1); scrolled = go_gtk_builder_get_widget (state->gui, "scrolled"); state->model = gtk_list_store_new (NUM_COLMNS, G_TYPE_STRING, G_TYPE_STRING); state->list = GTK_TREE_VIEW (gtk_tree_view_new_with_model (GTK_TREE_MODEL (state->model))); selection = gtk_tree_view_get_selection (state->list); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); column = gtk_tree_view_column_new_with_attributes (_("Input Data"), gtk_cell_renderer_text_new (), "text", DATA_RANGE, NULL); gtk_tree_view_column_set_sort_column_id (column, DATA_RANGE); gtk_tree_view_column_set_min_width (column, 150); gtk_tree_view_append_column (state->list, column); column = gtk_tree_view_column_new_with_attributes (_("Merge Field"), gtk_cell_renderer_text_new (), "text", FIELD_LOCATION, NULL); gtk_tree_view_column_set_sort_column_id (column, FIELD_LOCATION); gtk_tree_view_column_set_min_width (column, 100); gtk_tree_view_append_column (state->list, column); gtk_tree_view_set_headers_clickable (state->list, TRUE); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->list)); cb_merge_update_buttons (NULL, state); g_signal_connect (selection, "changed", G_CALLBACK (cb_merge_selection_changed), state); g_signal_connect_after (G_OBJECT (state->zone), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->data), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect_after (G_OBJECT (state->field), "changed", G_CALLBACK (cb_merge_update_buttons), state); g_signal_connect (G_OBJECT (state->add_btn), "clicked", G_CALLBACK (cb_merge_add_clicked), state); g_signal_connect (G_OBJECT (state->change_btn), "clicked", G_CALLBACK (cb_merge_change_clicked), state); g_signal_connect (G_OBJECT (state->delete_btn), "clicked", G_CALLBACK (cb_merge_delete_clicked), state); g_signal_connect (G_OBJECT (state->merge_btn), "clicked", G_CALLBACK (cb_merge_merge_clicked), state); g_signal_connect (G_OBJECT (state->cancel_btn), "clicked", G_CALLBACK (cb_merge_cancel_clicked), state); gnm_dialog_setup_destroy_handlers (GTK_DIALOG (state->dialog), state->wbcg, GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED); gnumeric_init_help_button ( go_gtk_builder_get_widget (state->gui, "help_button"), GNUMERIC_HELP_LINK_DATA_MERGE); gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog), MERGE_KEY); /* a candidate for merging into attach guru */ g_object_set_data_full (G_OBJECT (state->dialog), "state", state, (GDestroyNotify) cb_merge_destroy); go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg), GTK_WINDOW (state->dialog)); wbc_gtk_attach_guru (state->wbcg, GTK_WIDGET (state->dialog)); gtk_widget_show_all (GTK_WIDGET (state->dialog)); }
static void buttonize (GrubChooseDefaultButtonBox * box, GchdMenu *menu) { GrubChooseDefaultButtonBoxPrivate *priv = GET_PRIVATE (box); int i; GList *entries; GList *children, *iter; children = gtk_container_get_children(GTK_CONTAINER(box)); for(iter = children; iter != NULL; iter = g_list_next(iter)) gtk_widget_destroy(GTK_WIDGET(iter->data)); g_list_free(children); entries = menu->entries; if (priv->buttons) g_free (priv->buttons); priv->buttons = g_new (GtkWidget *, menu->n_entries); for (i=0; i<menu->n_entries && entries != NULL; i++, entries = g_list_next (entries)) { GtkWidget * button; GchdEntry* entry = entries->data; GtkWidget * label; priv->buttons[i] = button = gtk_button_new (); g_object_set_data (G_OBJECT (button), "entry", entry); label = gtk_label_new (""); if (strcmp (entry->name, priv->def_entry) == 0) { //gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL); //gtk_label_set_attributes (GTK_LABEL (label), "use-underline"); gchar * markup; markup = g_strdup_printf ("<b>%s</b>", entry->name); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); } else { gtk_label_set_text (GTK_LABEL (label), entry->name); } gtk_container_add (GTK_CONTAINER (button), label); gtk_widget_show (label); gtk_button_set_alignment (GTK_BUTTON (button), 0.0, 0.5); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked), box); gtk_widget_set_tooltip_markup (button, "Perform the action selected below on this boot entry."); gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0); gtk_widget_show (button); } }
static void rejilla_search_entry_init (RejillaSearchEntry *obj) { gchar *string; gpointer value; GtkWidget *table; GtkWidget *label; GtkWidget *entry; GtkListStore *store; GtkCellRenderer *renderer; GtkEntryCompletion *completion; gtk_table_set_row_spacings (GTK_TABLE (obj), 6); gtk_table_set_col_spacings (GTK_TABLE (obj), 6); gtk_table_resize (GTK_TABLE (obj), 2, 3); obj->priv = g_new0 (RejillaSearchEntryPrivate, 1); string = g_strdup_printf ("<b>%s</b>", _("Search:")); label = gtk_label_new (string); g_free (string); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_table_attach (GTK_TABLE (obj), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 2, 2); obj->priv->button = gtk_button_new_from_stock (GTK_STOCK_FIND); gtk_table_attach (GTK_TABLE (obj), obj->priv->button, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect (G_OBJECT (obj->priv->button), "clicked", G_CALLBACK (rejilla_search_entry_button_clicked_cb), obj); /* Set up the combo box */ store = gtk_list_store_new (REJILLA_SEARCH_ENTRY_NB_COL, G_TYPE_STRING, G_TYPE_STRING); obj->priv->combo = gtk_combo_box_entry_new_with_model (GTK_TREE_MODEL (store), REJILLA_SEARCH_ENTRY_DISPLAY_COL); g_object_unref (store); g_signal_connect (G_OBJECT (obj->priv->combo), "changed", G_CALLBACK (rejilla_search_entry_entry_activated_cb), obj); gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (obj->priv->combo), rejilla_search_entry_separator_func, obj, NULL); gtk_cell_layout_clear (GTK_CELL_LAYOUT (obj->priv->combo)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (obj->priv->combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (obj->priv->combo), renderer, "text", REJILLA_SEARCH_ENTRY_DISPLAY_COL, "background", REJILLA_SEARCH_ENTRY_BACKGRD_COL, NULL); /* set auto completion */ entry = gtk_bin_get_child (GTK_BIN (obj->priv->combo)); completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store)); gtk_entry_completion_set_text_column (completion, REJILLA_SEARCH_ENTRY_DISPLAY_COL); gtk_entry_set_completion (GTK_ENTRY (entry), completion); gtk_table_attach (GTK_TABLE (obj), obj->priv->combo, 1, 2, 0, 1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0); /* Table with filtering options */ table = gtk_table_new (2, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 10); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_attach (GTK_TABLE (obj), table, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); obj->priv->documents = gtk_check_button_new_with_mnemonic (_("In _text documents")); gtk_button_set_alignment (GTK_BUTTON (obj->priv->documents), 0.0, 0.0); gtk_table_attach (GTK_TABLE (table), obj->priv->documents, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect (obj->priv->documents, "clicked", G_CALLBACK (rejilla_search_entry_category_clicked_cb), obj); obj->priv->pictures = gtk_check_button_new_with_mnemonic (_("In _pictures")); gtk_button_set_alignment (GTK_BUTTON (obj->priv->pictures), 0.0, 0.0); gtk_table_attach (GTK_TABLE (table), obj->priv->pictures, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect (obj->priv->pictures, "clicked", G_CALLBACK (rejilla_search_entry_category_clicked_cb), obj); obj->priv->music = gtk_check_button_new_with_mnemonic (_("In _music")); gtk_button_set_alignment (GTK_BUTTON (obj->priv->music), 0.0, 0.0); gtk_table_attach (GTK_TABLE (table), obj->priv->music, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect (obj->priv->music, "clicked", G_CALLBACK (rejilla_search_entry_category_clicked_cb), obj); obj->priv->video = gtk_check_button_new_with_mnemonic (_("In _videos")); gtk_button_set_alignment (GTK_BUTTON (obj->priv->video), 0.0, 0.0); gtk_table_attach (GTK_TABLE (table), obj->priv->video, 2, 3, 1, 2, GTK_FILL, GTK_FILL, 0, 0); g_signal_connect (obj->priv->video, "clicked", G_CALLBACK (rejilla_search_entry_category_clicked_cb), obj); /* add tooltips */ gtk_widget_set_tooltip_text (gtk_bin_get_child (GTK_BIN (obj->priv->combo)), _("Type your keywords or choose 'All files' from the menu")); /* Translators: this is an image, a picture, not a "Disc Image" */ gtk_widget_set_tooltip_text (obj->priv->pictures, _("Select if you want to search among image files only")); gtk_widget_set_tooltip_text (obj->priv->video, _("Select if you want to search among video files only")); gtk_widget_set_tooltip_text (obj->priv->music, _("Select if you want to search among audio files only")); gtk_widget_set_tooltip_text (obj->priv->documents, _("Select if you want to search among your text documents only")); gtk_widget_set_tooltip_text (obj->priv->button, _("Click to start the search")); rejilla_setting_get_value (rejilla_setting_get_default (), REJILLA_SETTING_SEARCH_ENTRY_HISTORY, &value); rejilla_search_entry_set_history (obj, value); g_strfreev (value); }