void FileDialog::AddChildGTK(wxWindowGTK* child) { // allow dialog to be resized smaller horizontally gtk_widget_set_size_request( child->m_widget, child->GetMinWidth(), child->m_height); // In GTK 3+, adding our container as the extra widget can cause the // the filter combo to grow to the same height as our container. This // makes for a very odd looking filter combo. So, we manually add our // container below the action bar. #if GTK_CHECK_VERSION(3,0,0) GtkWidget *actionbar = find_widget(m_widget, "GtkActionBar", 0); if (actionbar) { GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(vbox), child->m_widget); gtk_box_set_child_packing(GTK_BOX(vbox), child->m_widget, TRUE, TRUE, 0, GTK_PACK_START); gtk_widget_show(vbox); GtkWidget *abparent = gtk_widget_get_parent(actionbar); gtk_container_add(GTK_CONTAINER(abparent), vbox); gtk_box_set_child_packing(GTK_BOX(abparent), vbox, FALSE, FALSE, 0, GTK_PACK_END); gtk_box_reorder_child(GTK_BOX(abparent), actionbar, -2); } #else gtk_file_chooser_set_extra_widget( GTK_FILE_CHOOSER(m_widget), child->m_widget); #endif }
void wxFrame::SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; if (toolbar) { if (toolbar->IsVertical()) { // Vertical toolbar and m_wxwindow go into an hbox, inside the // vbox (m_mainWidget). hbox is created on demand. GtkWidget* hbox = gtk_widget_get_parent(m_wxwindow); if (!GTK_IS_HBOX(hbox)) { hbox = gtk_hbox_new(false, 0); gtk_widget_show(hbox); gtk_container_add(GTK_CONTAINER(m_mainWidget), hbox); gtk_widget_reparent(m_wxwindow, hbox); } gtk_widget_reparent(toolbar->m_widget, hbox); gtk_box_set_child_packing(GTK_BOX(hbox), toolbar->m_widget, false, false, 0, GTK_PACK_START); int pos = 0; // left if (toolbar->HasFlag(wxTB_RIGHT)) pos = 1; // right gtk_box_reorder_child(GTK_BOX(hbox), toolbar->m_widget, pos); } else { // Horizontal toolbar goes into vbox (m_mainWidget) gtk_widget_reparent(toolbar->m_widget, m_mainWidget); gtk_box_set_child_packing(GTK_BOX(m_mainWidget), toolbar->m_widget, false, false, 0, GTK_PACK_START); int pos = 0; // top if (m_frameMenuBar) pos = 1; // below menubar if (toolbar->HasFlag(wxTB_BOTTOM)) pos += 2; // below client area (m_wxwindow) gtk_box_reorder_child( GTK_BOX(m_mainWidget), toolbar->m_widget, pos); } // disconnect wxWindowGTK "size_request" handler, // it interferes with sizing of detached GtkHandleBox gulong handler_id = g_signal_handler_find( toolbar->m_widget, GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA), g_signal_lookup("size_request", GTK_TYPE_WIDGET), 0, NULL, NULL, toolbar); if (handler_id != 0) g_signal_handler_disconnect(toolbar->m_widget, handler_id); // reset size request to allow native sizing to work gtk_widget_set_size_request(toolbar->m_widget, -1, -1); } // make sure next size_allocate causes a wxSizeEvent m_oldClientWidth = 0; }
static void battmon_set_size(Control *ctrl, int size) { t_battmon *battmon = (t_battmon *)ctrl->data; gtk_widget_set_size_request(battmon->vbox, icon_size[size] * battmon->options.hsize, icon_size[size] /* * battmon->options.vsize */); gtk_widget_set_size_request(battmon->battstatus, icon_size[size] * battmon->options.hsize, icon_size[size] * battmon->options.vsize); if(battmon->options.vsize < 1) gtk_box_set_child_packing(GTK_BOX(battmon->vbox), battmon->ebox, FALSE, FALSE, icon_size[size] * (1 - battmon->options.vsize) / 2, GTK_PACK_START); else gtk_box_set_child_packing(GTK_BOX(battmon->vbox), battmon->ebox, FALSE, FALSE, 0, GTK_PACK_START); }
void wxFrame::SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; if (toolbar) { if (toolbar->IsVertical()) { // Vertical toolbar and m_wxwindow go into an hbox, inside the // vbox (m_mainWidget). hbox is created on demand. GtkWidget* hbox = gtk_widget_get_parent(m_wxwindow); if (hbox == m_mainWidget) { hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_show(hbox); gtk_box_pack_start(GTK_BOX(m_mainWidget), hbox, true, true, 0); gtk_widget_reparent(m_wxwindow, hbox); } gtk_widget_reparent(toolbar->m_widget, hbox); gtk_box_set_child_packing(GTK_BOX(hbox), toolbar->m_widget, false, false, 0, GTK_PACK_START); int pos = 0; // left if (toolbar->HasFlag(wxTB_RIGHT)) pos = 1; // right gtk_box_reorder_child(GTK_BOX(hbox), toolbar->m_widget, pos); } else { // Horizontal toolbar goes into vbox (m_mainWidget) gtk_widget_reparent(toolbar->m_widget, m_mainWidget); gtk_box_set_child_packing(GTK_BOX(m_mainWidget), toolbar->m_widget, false, false, 0, GTK_PACK_START); int pos = 0; // top if (m_frameMenuBar) pos = 1; // below menubar if (toolbar->HasFlag(wxTB_BOTTOM)) pos += 2; // below client area (m_wxwindow) gtk_box_reorder_child( GTK_BOX(m_mainWidget), toolbar->m_widget, pos); } // reset size request to allow native sizing to work gtk_widget_set_size_request(toolbar->m_widget, -1, -1); } // make sure next size_allocate causes a wxSizeEvent m_useCachedClientSize = false; m_clientWidth = 0; }
void wxNotebook::SetPadding( const wxSize &padding ) { wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); m_padding = padding.GetWidth(); int i; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i=0; i<int(GetPageCount()); i++) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); wxASSERT(nb_page != NULL); if (nb_page->m_image != -1) { // gtk_box_set_child_packing sets padding on BOTH sides // icon provides left padding, label provides center and right int image = nb_page->m_image; SetPageImage(i,-1); SetPageImage(i,image); } wxASSERT(nb_page->m_label); gtk_box_set_child_packing(GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding, GTK_PACK_END); } }
static void set_xml_string(GelUIGeneric *self, const gchar *xml_string) { g_return_if_fail(GEL_UI_IS_GENERIC(self)); g_return_if_fail(xml_string != NULL); GelUIGenericPrivate *priv = self->priv; g_return_if_fail(priv->builder == NULL); priv->builder = gtk_builder_new(); GError *error = NULL; if (!gtk_builder_add_from_string(priv->builder, xml_string, -1, &error)) { g_warning(_("Cannot load UI from string: %s"), error->message); g_error_free(error); return; } GtkWidget *w = GTK_WIDGET(gtk_builder_get_object(priv->builder, "main-widget")); if (w == NULL) { g_warning(_("Cannot find widget 'main-widget' on UI")); return; } gtk_widget_reparent(w, (GtkWidget *) self); gtk_box_set_child_packing ((GtkBox *) self, w, TRUE, TRUE, 0, GTK_PACK_START); g_object_notify(G_OBJECT(self), "xml-string"); }
void wxNotebook::SetPadding( const wxSize &padding ) { wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); m_padding = padding.GetWidth(); int i; for (i=0; i<int(GetPageCount()); i++) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); wxASSERT(nb_page != NULL); if (nb_page->m_image != -1) { // gtk_box_set_child_packing sets padding on BOTH sides // icon provides left padding, label provides center and right int image = nb_page->m_image; SetPageImage(i,-1); SetPageImage(i,image); } wxASSERT(nb_page->m_label); gtk_box_set_child_packing(GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding, GTK_PACK_END); } }
void wxNotebook::SetPadding( const wxSize &padding ) { wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); m_padding = padding.GetWidth(); for (size_t i = GetPageCount(); i--;) { wxGtkNotebookPage* pageData = GetNotebookPage(i); if (pageData->m_image) { gtk_box_set_child_packing(GTK_BOX(pageData->m_box), pageData->m_image, false, false, m_padding, GTK_PACK_START); } gtk_box_set_child_packing(GTK_BOX(pageData->m_box), pageData->m_label, false, false, m_padding, GTK_PACK_END); } }
/* Applies or loads the child properties of a child of a hbox/vbox. */ void gb_box_set_child_properties (GtkWidget *widget, GtkWidget *child, GbWidgetSetArgData *data) { gint position, padding; guint old_padding; gboolean expand, fill, pack, set_child_packing = FALSE; gboolean old_expand, old_fill; GtkPackType old_pack_type; position = gb_widget_input_int (data, GbPosition); if (data->apply) { gtk_box_reorder_child (GTK_BOX (widget), child, position); } gtk_box_query_child_packing (GTK_BOX (widget), child, &old_expand, &old_fill, &old_padding, &old_pack_type); padding = gb_widget_input_int (data, GbPadding); if (data->apply) set_child_packing = TRUE; else padding = old_padding; expand = gb_widget_input_bool (data, GbExpand); if (data->apply) set_child_packing = TRUE; else expand = old_expand; fill = gb_widget_input_bool (data, GbFill); if (data->apply) set_child_packing = TRUE; else fill = old_fill; if (data->action == GB_APPLYING) { pack = gb_widget_input_bool (data, GbPack); } else { gchar *pack_symbol = gb_widget_input_string (data, GbPack); pack = pack_symbol && !strcmp (pack_symbol, "GTK_PACK_START"); } if (data->apply) set_child_packing = TRUE; else pack = (old_pack_type == GTK_PACK_START) ? TRUE : FALSE; if (set_child_packing) gtk_box_set_child_packing (GTK_BOX (widget), child, expand, fill, padding, pack ? GTK_PACK_START : GTK_PACK_END); }
void ygtk_field_entry_setup_field (YGtkFieldEntry *fields, guint index, gint max_length, const gchar *valid_chars) { GtkEntry *entry = ygtk_field_entry_get_field_widget (fields, index); gboolean disable_len = (max_length <= 0); gtk_entry_set_max_length (entry, disable_len ? 0 : max_length); gtk_entry_set_width_chars (entry, disable_len ? -1 : max_length); gtk_box_set_child_packing (GTK_BOX (fields), GTK_WIDGET (entry), disable_len, TRUE, 0, GTK_PACK_START); ygutils_setFilter (entry, valid_chars); }
JNIEXPORT void JNICALL Java_org_gnome_gtk_GtkBox_gtk_1box_1set_1child_1packing ( JNIEnv* env, jclass cls, jlong _self, jlong _child, jboolean _expand, jboolean _fill, jint _padding, jint _packType ) { GtkBox* self; GtkWidget* child; gboolean expand; gboolean fill; guint padding; GtkPackType packType; // convert parameter self self = (GtkBox*) _self; // convert parameter child child = (GtkWidget*) _child; // convert parameter expand expand = (gboolean) _expand; // convert parameter fill fill = (gboolean) _fill; // convert parameter padding padding = (guint) _padding; // convert parameter packType packType = (GtkPackType) _packType; // call function gtk_box_set_child_packing(self, child, expand, fill, padding, packType); // cleanup parameter self // cleanup parameter child // cleanup parameter expand // cleanup parameter fill // cleanup parameter padding // cleanup parameter packType }
void set_panarea_padding(GtkWidget *child, gpointer data) { void set_child_padding(GtkWidget *child, gpointer user_data) { GtkBox *box = GTK_BOX(user_data); gboolean expand, fill; guint pad; GtkPackType pack; gtk_box_query_child_packing(box, child, &expand, &fill, &pad, &pack); gtk_box_set_child_packing(box, child, expand, fill, 0, pack); }
static void createTab(char *name) { logInfo("Creating IRC console tab '%s'", name); char *dupname = strdup(name); // vertical layout GtkWidget *vLayout = gtk_vbox_new(false, 1); // scroll GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(vLayout), GTK_WIDGET(scroll)); GtkWidget *input = gtk_entry_new(); GtkRcStyle *style = gtk_widget_get_modifier_style(GTK_WIDGET(input)); PangoFontDescription *font = pango_font_description_from_string("Monospace Normal"); style->font_desc = font; gtk_widget_modify_style(GTK_WIDGET(input), style); gtk_container_add(GTK_CONTAINER(vLayout), GTK_WIDGET(input)); g_signal_connect(GTK_OBJECT(input), "activate", GTK_SIGNAL_FUNC(inputActivate), dupname); gtk_box_set_child_packing(GTK_BOX(vLayout), GTK_WIDGET(input), false, true, 0, GTK_PACK_END); // list GtkWidget *list = gtk_tree_view_new(); gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(list)); // list columns gtk_tree_view_append_column(GTK_TREE_VIEW(list), gtk_tree_view_column_new_with_attributes("Timestamp", gtk_cell_renderer_text_new(), "text", ROW_TIME, NULL)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Message", renderer, "text", ROW_MESSAGE, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_column_set_cell_data_func(column, renderer, &formatMessageCell, NULL, NULL); // create store GtkListStore *store = gtk_list_store_new(N_ROWS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store)); GtkWidget *title = gtk_label_new(name); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), GTK_WIDGET(vLayout), GTK_WIDGET(title)); IrcConsoleTab *tab = ALLOCATE_OBJECT(IrcConsoleTab); g_object_ref(G_OBJECT(list)); tab->lines = 0; tab->list = list; tab->store = store; g_hash_table_insert(tabs, dupname, tab); gtk_widget_show_all(GTK_WIDGET(notebook)); }
int assemble_views() { /* button2 */ make_button2(); /*status*/ make_status(); /*scroll*/ make_scroll(); /*textview*/ make_textview(); /* tags */ make_tags(); gtk_container_add((GtkContainer *)hbox1, button2); gtk_box_set_child_packing(GTK_BOX(hbox1), button2, 0, 0, 1, GTK_PACK_START); gtk_container_add((GtkContainer *)hboxmain, textview1); gtk_container_add((GtkContainer *)scroll, textview2); gtk_container_add((GtkContainer *)hboxmain, scroll); gtk_container_add((GtkContainer *)vbox1, GTK_WIDGET(status)); gtk_box_set_child_packing(GTK_BOX(hboxmain), textview1, 0, 1, 2, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(hboxmain), scroll, 1, 1, 2, GTK_PACK_END); gtk_box_set_child_packing(GTK_BOX(vbox1), GTK_WIDGET(status), 0, 1, 0, GTK_PACK_START); gtk_widget_show(scroll); viewsAssembled = TRUE; debug("Assemble views"); return 0; }
static void ViewAutoDrawerRefreshPacking(ViewAutoDrawer *that) // IN { gboolean expand; gboolean fill; guint padding; expand = (that->priv->fill || (that->priv->offset < 0)); fill = that->priv->fill; padding = (expand || fill) ? 0 : that->priv->offset; gtk_box_set_child_packing(GTK_BOX(that), that->priv->evBox, expand, fill, padding, GTK_PACK_START); }
void wxFrame::SetStatusBar(wxStatusBar *statbar) { m_frameStatusBar = statbar; if (statbar) { // statusbar goes into bottom of vbox (m_mainWidget) gtk_widget_reparent(statbar->m_widget, m_mainWidget); gtk_box_set_child_packing(GTK_BOX(m_mainWidget), statbar->m_widget, false, false, 0, GTK_PACK_END); // make sure next size_allocate on statusbar causes a size event statbar->m_oldClientWidth = 0; } // make sure next size_allocate causes a wxSizeEvent m_oldClientWidth = 0; }
static GtkCList *mmio_window_add_page( mmio_window_t mmio, char *name, struct mmio_region *io_rgn ) { GtkCList *list; GtkWidget *scroll; GtkWidget *tab; GtkCheckButton *trace_button; GtkVBox *vbox; scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS ); list = GTK_CLIST(gtk_clist_new(5)); gtk_clist_set_column_width(list, 0, 70); gtk_clist_set_column_width(list, 1, 75); gtk_clist_set_column_width(list, 2, 70); gtk_clist_set_column_width(list, 3, 280); gtk_clist_set_column_width(list, 4, 160); gtk_clist_set_column_justification(list, 0, GTK_JUSTIFY_CENTER ); gtk_clist_set_column_justification(list, 2, GTK_JUSTIFY_CENTER ); gtk_clist_set_column_justification(list, 3, GTK_JUSTIFY_CENTER ); gtk_clist_set_column_title(list, 0, _("Address")); gtk_clist_set_column_title(list, 1, _("Register")); gtk_clist_set_column_title(list, 2, _("Value")); gtk_clist_set_column_title(list, 3, _("Bit Pattern")); gtk_clist_set_column_title(list, 4, _("Description")); gtk_clist_column_titles_show(list); gtk_widget_modify_font( GTK_WIDGET(list), gui_fixed_font ); tab = gtk_label_new(_(name)); gtk_container_add( GTK_CONTAINER(scroll), GTK_WIDGET(list) ); vbox = GTK_VBOX(gtk_vbox_new( FALSE, 0 )); gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(scroll) ); trace_button = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(_("Trace access"))); if( io_rgn != NULL ) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trace_button), io_rgn->trace_flag ? TRUE : FALSE); } gtk_container_add( GTK_CONTAINER(vbox), GTK_WIDGET(trace_button) ); gtk_box_set_child_packing( GTK_BOX(vbox), GTK_WIDGET(trace_button), FALSE, FALSE, 0, GTK_PACK_START ); gtk_notebook_append_page( GTK_NOTEBOOK(mmio->notebook), GTK_WIDGET(vbox), tab ); gtk_object_set_data( GTK_OBJECT(mmio->window), name, list ); g_signal_connect ((gpointer) trace_button, "toggled", G_CALLBACK (on_trace_button_toggled), io_rgn); return list; }
void go_gtk_widget_replace (GtkWidget *victim, GtkWidget *replacement) { GtkContainer *parent = GTK_CONTAINER (gtk_widget_get_parent (victim)); if (GTK_IS_GRID (parent)) { int col, row, width, height; gtk_container_child_get (parent, victim, "left-attach", &col, "top-attach", &row, "width", &width, "height", &height, NULL); gtk_container_remove (parent, victim); gtk_grid_attach (GTK_GRID (parent), replacement, col, row, width, height); } else if (GTK_IS_BOX (parent)) { GtkBox *box = GTK_BOX (parent); gboolean expand, fill; guint padding; GtkPackType pack_type; int pos; gtk_box_query_child_packing (box, victim, &expand, &fill, &padding, &pack_type); gtk_container_child_get (parent, victim, "position", &pos, NULL); gtk_container_remove (parent, victim); gtk_container_add (parent, replacement); gtk_box_set_child_packing (box, replacement, expand, fill, padding, pack_type); gtk_box_reorder_child (box, replacement, pos); } else { g_error ("Unsupported container: %s", g_type_name_from_instance ((gpointer)parent)); } }
void wxFrame::SetStatusBar(wxStatusBar *statbar) { m_frameStatusBar = statbar; if (statbar) { // statusbar goes into bottom of vbox (m_mainWidget) gtk_widget_reparent(statbar->m_widget, m_mainWidget); gtk_box_set_child_packing(GTK_BOX(m_mainWidget), statbar->m_widget, false, false, 0, GTK_PACK_END); // make sure next size_allocate on statusbar causes a size event statbar->m_oldClientWidth = 0; int h = -1; if (statbar->m_wxwindow) { // statusbar is not a native widget, need to set height request h = statbar->m_height; } gtk_widget_set_size_request(statbar->m_widget, -1, h); } // make sure next size_allocate causes a wxSizeEvent m_oldClientWidth = 0; }
/* Create widgets to represent the options made available by the backend */ void xkb_options_load_options (GtkBuilder * dialog) { GtkWidget *opts_vbox = WID ("options_vbox"); GtkWidget *dialog_vbox = WID ("dialog_vbox"); GtkWidget *options_scroll = WID ("options_scroll"); GtkWidget *expander; GSList *expanders_list; current1st_level_id = NULL; current_none_radio = NULL; current_multi_select = FALSE; current_radio_group = NULL; /* fill the list */ xkl_config_registry_foreach_option_group (config_registry, (ConfigItemProcessFunc) xkb_options_add_group, dialog); /* sort it */ expanders_list = g_object_get_data (G_OBJECT (dialog), EXPANDERS_PROP); expanders_list = g_slist_sort (expanders_list, (GCompareFunc) xkb_options_expanders_compare); g_object_set_data (G_OBJECT (dialog), EXPANDERS_PROP, expanders_list); while (expanders_list) { expander = GTK_WIDGET (expanders_list->data); gtk_box_pack_start (GTK_BOX (opts_vbox), expander, FALSE, FALSE, 0); expanders_list = expanders_list->next; } /* Somewhere in gtk3 the top vbox in dialog is made non-expandable */ gtk_box_set_child_packing (GTK_BOX (dialog_vbox), options_scroll, TRUE, TRUE, 0, GTK_PACK_START); gtk_widget_show_all (dialog_vbox); }
static gboolean internal_init (NMAWirelessDialog *self, NMConnection *specific_connection, NMDevice *specific_device, gboolean auth_only, gboolean create) { NMAWirelessDialogPrivate *priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self); GtkWidget *widget; char *label, *icon_name = "network-wireless"; gboolean security_combo_focus = FALSE; gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER_ALWAYS); gtk_container_set_border_width (GTK_CONTAINER (self), 6); gtk_window_set_default_size (GTK_WINDOW (self), 488, -1); gtk_window_set_resizable (GTK_WINDOW (self), FALSE); gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); if (auth_only) icon_name = "dialog-password"; else icon_name = "network-wireless"; gtk_window_set_icon_name (GTK_WINDOW (self), icon_name); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "image1")); gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, GTK_ICON_SIZE_DIALOG); gtk_box_set_spacing (GTK_BOX (gtk_bin_get_child (GTK_BIN (self))), 2); widget = gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_box_set_child_packing (GTK_BOX (GTK_DIALOG (self)->action_area), widget, FALSE, TRUE, 0, GTK_PACK_END); /* Connect/Create button */ if (create) { GtkWidget *image; widget = gtk_button_new_with_mnemonic (_("C_reate")); image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (widget), image); gtk_widget_show (widget); gtk_dialog_add_action_widget (GTK_DIALOG (self), widget, GTK_RESPONSE_OK); } else widget = gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CONNECT, GTK_RESPONSE_OK); gtk_box_set_child_packing (GTK_BOX (GTK_DIALOG (self)->action_area), widget, FALSE, TRUE, 0, GTK_PACK_END); g_object_set (G_OBJECT (widget), "can-default", TRUE, NULL); gtk_widget_grab_default (widget); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "hbox1")); if (!widget) { nm_warning ("Couldn't find UI wireless_dialog widget."); return FALSE; } gtk_widget_reparent (widget, gtk_bin_get_child (GTK_BIN (self))); /* If given a valid connection, hide the SSID bits and connection combo */ if (specific_connection) { widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_label")); gtk_widget_hide (widget); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry")); gtk_widget_hide (widget); security_combo_focus = TRUE; } else { widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "network_name_entry")); g_signal_connect (G_OBJECT (widget), "changed", (GCallback) ssid_entry_changed, self); gtk_widget_grab_focus (widget); } gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE); if (!device_combo_init (self, specific_device)) { g_warning ("No wireless devices available."); return FALSE; } if (!connection_combo_init (self, specific_connection)) { g_warning ("Couldn't set up connection combo box."); return FALSE; } if (!security_combo_init (self)) { g_warning ("Couldn't set up wireless security combo box."); return FALSE; } if (security_combo_focus) gtk_widget_grab_focus (priv->sec_combo); security_combo_changed (priv->sec_combo, self); g_signal_connect (G_OBJECT (priv->sec_combo), "changed", G_CALLBACK (security_combo_changed), self); if (priv->connection) { char *tmp; char *esc_ssid = NULL; NMSettingWireless *s_wireless; const GByteArray *ssid; s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS)); ssid = s_wireless ? nm_setting_wireless_get_ssid (s_wireless) : NULL; if (ssid) esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len); tmp = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."), esc_ssid ? esc_ssid : "<unknown>"); gtk_window_set_title (GTK_WINDOW (self), _("Wireless Network Authentication Required")); label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s", _("Authentication required by wireless network"), tmp); g_free (esc_ssid); g_free (tmp); } else if (priv->adhoc_create) { gtk_window_set_title (GTK_WINDOW (self), _("Create New Wireless Network")); label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s", _("New wireless network"), _("Enter a name for the wireless network you wish to create.")); } else { gtk_window_set_title (GTK_WINDOW (self), _("Connect to Hidden Wireless Network")); label = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s", _("Hidden wireless network"), _("Enter the name and security details of the hidden wireless network you wish to connect to.")); } widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "caption_label")); gtk_label_set_markup (GTK_LABEL (widget), label); g_free (label); /* Re-validate from an idle handler so that widgets like file choosers * have had time to find their files. */ g_idle_add (revalidate, self); return TRUE; }
/*------------------------------main-----------------------------------*/ int main(int argc, char const *argv[]) { debug("main"); /*command line args*/ if(argc > 1) { if(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { printf("%s\n", HELPMSG); return 0; } if(!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) { printf("%s\n", VERSION); return 0; } printf("Unknown args [%s], continue to GUI...\n", argv[1]); } /*gtk start*/ gtk_init(NULL, NULL); debug("gtk init"); /*init char*/ mark = malloc(2); word = malloc(MAX_LENGTH); /* init curl */ curl_global_init(CURL_GLOBAL_ALL); debug("curl init"); /*window*/ window = (GtkWidget *)gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_set_icon_name(GTK_WINDOW(window),"accessories-dictionary"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_CENTER); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "key_press_event", G_CALLBACK(checkEsc), NULL); debug("window"); /* entry */ make_entry(); /*button*/ make_button1(); /*assemble*/ vbox1 = gtk_vbox_new(FALSE, 2); /*h**o, pad*/ hbox1 = gtk_hbox_new(FALSE, 2); hboxmain = gtk_hbox_new(FALSE, 5); gtk_widget_set_no_show_all(hboxmain, TRUE); gtk_container_add((GtkContainer *)window, vbox1); gtk_container_add((GtkContainer *)vbox1, hbox1); gtk_container_add((GtkContainer *)vbox1, hboxmain); gtk_container_add((GtkContainer *)hbox1, entry); gtk_container_add((GtkContainer *)hbox1, button1); gtk_box_set_child_packing(GTK_BOX(hbox1), GTK_WIDGET(entry), 1,/*expand*/ 1,/*fill*/ 2,/*pad*/ GTK_PACK_START/*pack type*/ ); gtk_box_set_child_packing(GTK_BOX(vbox1), hbox1, 0, 0, 1, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(hbox1), button1, 0, 0, 1, GTK_PACK_START); debug("assemble initial view"); gtk_widget_show_all(window); debug("start the show"); #ifdef MinGW /*volatino*/ volatino = (GtkWidget *) gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_decorated(GTK_WINDOW(volatino), FALSE); gtk_widget_set_size_request(volatino, 450, 24); gtk_window_set_icon_name(GTK_WINDOW(volatino),"accessories-dictionary"); gtk_window_set_position(GTK_WINDOW(volatino), GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_gravity(GTK_WINDOW(volatino), GDK_GRAVITY_CENTER); gtk_widget_show(volatino); gtk_widget_destroy(volatino); #endif /*auto-completion*/ store = gtk_list_store_new(1, G_TYPE_STRING); model = GTK_TREE_MODEL(store); /*completion model*/ completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, model); gtk_entry_completion_set_text_column(completion, 0); /*completion style*/ gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_completion_set_inline_selection(completion, TRUE); /*commands*/ append_list(store, ":about"); append_list(store, ":help"); /*connect completion*/ gtk_entry_set_completion(GTK_ENTRY(entry), completion); debug("completion"); debug("gtk main entering"); gtk_main(); /*gtk end*/ debug("Sure."); /*clean up*/ if(curl_handle) curl_easy_cleanup(curl_handle); curl_global_cleanup(); free(s); free(rslt); free(mark); free(word); if(searchStr) free(searchStr); return 0; }
/* * Public API */ GtkWidget * addressbook_window_new (boost::shared_ptr<Ekiga::ContactCore> core) { AddressBookWindow *self = NULL; boost::signals::connection conn; GtkWidget *menu_bar = NULL; GtkWidget *frame = NULL; GtkWidget *vbox = NULL; GtkWidget *hpaned = NULL; GtkCellRenderer *cell = NULL; GtkTreeViewColumn *column = NULL; GtkTreeStore *store = NULL; self = (AddressBookWindow *) g_object_new (ADDRESSBOOK_WINDOW_TYPE, NULL); self->priv = new AddressBookWindowPrivate (core); gtk_window_set_title (GTK_WINDOW (self), _("Address Book")); gtk_window_set_position (GTK_WINDOW (self), GTK_WIN_POS_CENTER); gtk_window_set_icon_name (GTK_WINDOW (self), "x-office-address-book"); /* Start building the window */ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); /* The menu */ menu_bar = gtk_menu_bar_new (); self->priv->accel = gtk_accel_group_new (); gtk_window_add_accel_group (GTK_WINDOW (self), self->priv->accel); g_object_unref (self->priv->accel); self->priv->menu_item_core = gtk_menu_item_new_with_mnemonic (_("Address _Book")); gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), self->priv->menu_item_core); g_object_ref (self->priv->menu_item_core); conn = core->updated.connect (boost::bind (&on_core_updated, (gpointer) self)); self->priv->connections.add (conn); on_core_updated (self); // This will add static and dynamic actions self->priv->menu_item_view = gtk_menu_item_new_with_mnemonic (_("_Action")); gtk_widget_set_sensitive (self->priv->menu_item_view, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), self->priv->menu_item_view); g_object_ref (self->priv->menu_item_view); gtk_container_add (GTK_CONTAINER (vbox), menu_bar); gtk_box_set_child_packing (GTK_BOX (vbox), menu_bar, FALSE, FALSE, 2, GTK_PACK_START); gtk_container_add (GTK_CONTAINER (self), vbox); /* A hpaned to put the list of Books and their content */ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_container_set_border_width (GTK_CONTAINER (hpaned), 6); gtk_container_add (GTK_CONTAINER (vbox), hpaned); gtk_box_set_child_packing (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0, GTK_PACK_START); /* The store listing the Books */ frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); store = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_OBJECT); self->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (store); gtk_container_add (GTK_CONTAINER (frame), self->priv->tree_view); gtk_widget_set_size_request (GTK_WIDGET (self->priv->tree_view), 185, -1); gtk_paned_pack1 (GTK_PANED (hpaned), frame, TRUE, TRUE); /* Several renderers for one column */ column = gtk_tree_view_column_new (); cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_add_attribute (column, cell, "icon-name", COLUMN_PIXBUF); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, "text", COLUMN_NAME, NULL); gtk_tree_view_column_set_title (column, _("Category")); gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME); gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_column_set_resizable (GTK_TREE_VIEW_COLUMN (column), true); gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->tree_view), GTK_TREE_VIEW_COLUMN (column)); self->priv->selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->tree_view)); gtk_tree_selection_set_mode (GTK_TREE_SELECTION (self->priv->selection), GTK_SELECTION_SINGLE); g_signal_connect (self->priv->selection, "changed", G_CALLBACK (on_book_selection_changed), self); g_signal_connect (self->priv->tree_view, "event-after", G_CALLBACK (on_book_clicked), self); /* The notebook containing the books */ self->priv->notebook = gtk_notebook_new (); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->priv->notebook), FALSE); g_signal_connect (self->priv->notebook, "realize", G_CALLBACK (on_notebook_realize), self); gtk_paned_pack2 (GTK_PANED (hpaned), self->priv->notebook, TRUE, TRUE); conn = core->source_added.connect (boost::bind (&on_source_added, _1, (gpointer) self)); self->priv->connections.add (conn); conn = core->book_updated.connect (boost::bind (&on_book_updated, _1, _2, (gpointer) self)); self->priv->connections.add (conn); conn = core->book_added.connect (boost::bind (&on_book_added, _1, _2, (gpointer) self)); self->priv->connections.add (conn); conn = core->book_removed.connect (boost::bind (&on_book_removed, _1, _2, (gpointer) self)); self->priv->connections.add (conn); conn = core->questions.connect (boost::bind (&on_handle_questions, _1, (gpointer) self)); self->priv->connections.add (conn); core->visit_sources (boost::bind (on_visit_sources, _1, (gpointer) self)); return GTK_WIDGET (self); }
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); }
Client * newclient(void) { int i; Client *c; WebKitWebSettings *settings; GdkGeometry hints = { 1, 1 }; char *uri, *ua; if(!(c = calloc(1, sizeof(Client)))) die("Cannot malloc!\n"); /* Window */ if(embed) { c->win = gtk_plug_new(embed); } else { c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); /* TA: 20091214: Despite what the GNOME docs say, the ICCCM * is always correct, so we should still call this function. * But when doing so, we *must* differentiate between a * WM_CLASS and a resource on the window. By convention, the * window class (WM_CLASS) is capped, while the resource is in * lowercase. Both these values come as a pair. */ gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf"); /* TA: 20091214: And set the role here as well -- so that * sessions can pick this up. */ gtk_window_set_role(GTK_WINDOW(c->win), "Surf"); } gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600); g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c); g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c); g_signal_connect(G_OBJECT(c->win), "size-allocate", G_CALLBACK(resize), c); if(!(c->items = calloc(1, sizeof(GtkWidget *) * LENGTH(items)))) die("Cannot malloc!\n"); /* contextmenu */ for(i = 0; i < LENGTH(items); i++) { c->items[i] = gtk_menu_item_new_with_label(items[i].label); g_signal_connect(G_OBJECT(c->items[i]), "activate", G_CALLBACK(itemclick), c); } /* VBox */ c->vbox = gtk_vbox_new(FALSE, 0); /* Scrolled Window */ c->scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); /* Webview */ c->view = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c); g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c); g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c); g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c); g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c); g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(createwindow), c); g_signal_connect(G_OBJECT(c->view), "new-window-policy-decision-requested", G_CALLBACK(decidewindow), c); g_signal_connect(G_OBJECT(c->view), "mime-type-policy-decision-requested", G_CALLBACK(decidedownload), c); g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c); g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c); g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(context), c); /* Indicator */ c->indicator = gtk_drawing_area_new(); gtk_widget_set_size_request(c->indicator, 0, 2); g_signal_connect (G_OBJECT (c->indicator), "expose_event", G_CALLBACK (exposeindicator), c); /* Arranging */ gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view)); gtk_container_add(GTK_CONTAINER(c->win), c->vbox); gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll); gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator); /* Setup */ gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START); gtk_widget_grab_focus(GTK_WIDGET(c->view)); gtk_widget_show(c->vbox); gtk_widget_show(c->indicator); gtk_widget_show(c->scroll); gtk_widget_show(GTK_WIDGET(c->view)); gtk_widget_show(c->win); gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, GDK_HINT_MIN_SIZE); gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK); gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c); webkit_web_view_set_full_content_zoom(c->view, TRUE); settings = webkit_web_view_get_settings(c->view); if(!(ua = getenv("SURF_USERAGENT"))) ua = useragent; g_object_set(G_OBJECT(settings), "user-agent", ua, NULL); uri = g_strconcat("file://", stylefile, NULL); g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL); g_free(uri); setatom(c, findprop, ""); c->download = NULL; c->title = NULL; c->next = clients; clients = c; if(showxid) { gdk_display_sync(gtk_widget_get_display(c->win)); printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); fflush(NULL); } return c; }
bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { m_pos = value; m_scrollEventType = GTK_SCROLL_NONE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxSlider creation failed") ); return false; } if (style & wxSL_VERTICAL) m_scale = gtk_vscale_new( NULL ); else m_scale = gtk_hscale_new( NULL ); g_object_ref(m_scale); if (style & wxSL_MIN_MAX_LABELS) { gtk_widget_show( m_scale ); if (style & wxSL_VERTICAL) m_widget = gtk_hbox_new(false, 0); else m_widget = gtk_vbox_new(false, 0); g_object_ref(m_widget); gtk_container_add( GTK_CONTAINER(m_widget), m_scale ); GtkWidget *box; if (style & wxSL_VERTICAL) box = gtk_vbox_new(false,0); else box = gtk_hbox_new(false,0); g_object_ref(box); gtk_widget_show(box); gtk_container_add( GTK_CONTAINER(m_widget), box ); m_minLabel = gtk_label_new(NULL); g_object_ref(m_minLabel); gtk_widget_show( m_minLabel ); gtk_container_add( GTK_CONTAINER(box), m_minLabel ); gtk_box_set_child_packing( GTK_BOX(box), m_minLabel, FALSE, FALSE, 0, GTK_PACK_START ); // expanding empty space between the min/max labels GtkWidget *space = gtk_label_new(NULL); g_object_ref(space); gtk_widget_show( space ); gtk_container_add( GTK_CONTAINER(box), space ); gtk_box_set_child_packing( GTK_BOX(box), space, TRUE, FALSE, 0, GTK_PACK_START ); m_maxLabel = gtk_label_new(NULL); g_object_ref(m_maxLabel); gtk_widget_show( m_maxLabel ); gtk_container_add( GTK_CONTAINER(box), m_maxLabel ); gtk_box_set_child_packing( GTK_BOX(box), m_maxLabel, FALSE, FALSE, 0, GTK_PACK_END ); } else { m_widget = m_scale; m_maxLabel = NULL; m_minLabel = NULL; } const bool showValueLabel = (style & wxSL_VALUE_LABEL) != 0; gtk_scale_set_draw_value(GTK_SCALE (m_scale), showValueLabel ); if ( showValueLabel ) { // position the label appropriately: notice that wxSL_DIRECTION flags // specify the position of the ticks, not label, under MSW and so the // label is on the opposite side GtkPositionType posLabel; if ( style & wxSL_VERTICAL ) { if ( style & wxSL_LEFT ) posLabel = GTK_POS_RIGHT; else // if ( style & wxSL_RIGHT ) -- this is also the default posLabel = GTK_POS_LEFT; } else // horizontal slider { if ( style & wxSL_TOP ) posLabel = GTK_POS_BOTTOM; else // if ( style & wxSL_BOTTOM) -- this is again the default posLabel = GTK_POS_TOP; } gtk_scale_set_value_pos( GTK_SCALE(m_scale), posLabel ); } // Keep full precision in position value gtk_scale_set_digits(GTK_SCALE (m_scale), -1); if (style & wxSL_INVERSE) gtk_range_set_inverted( GTK_RANGE(m_scale), TRUE ); g_signal_connect(m_scale, "button_press_event", G_CALLBACK(gtk_button_press_event), this); g_signal_connect(m_scale, "button_release_event", G_CALLBACK(gtk_button_release_event), this); g_signal_connect(m_scale, "move_slider", G_CALLBACK(gtk_move_slider), this); g_signal_connect(m_scale, "format_value", G_CALLBACK(gtk_format_value), NULL); g_signal_connect(m_scale, "value_changed", G_CALLBACK(gtk_value_changed), this); gulong handler_id = g_signal_connect(m_scale, "event_after", G_CALLBACK(gtk_event_after), this); g_signal_handler_block(m_scale, handler_id); SetRange( minValue, maxValue ); // don't call the public SetValue() as it won't do anything unless the // value really changed GTKSetValue( value ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
void wibuti_widget_set_expand_title(WibutiWidget *self, gboolean expand_title) { self->expand_title = expand_title; gtk_box_set_child_packing(GTK_BOX(self->box), GTK_WIDGET(self->evbox_title), expand_title, TRUE, 0, GTK_PACK_START); }
static int getobjects(GtkBuilder *b) { GtkWidget *hbox; GtkWidget *scrollDone, *scrollQueue; #define GET_WIDGET2(x, n) \ if(!((x) = GTK_WIDGET(gtk_builder_get_object(b, n)))){ \ fputs("Error: Couldn't get Gtk Widget " #x " = \"" n "\", bailing\n", stderr); \ return 1; \ } #define GET_WIDGET(x) \ if(!((x) = GTK_WIDGET(gtk_builder_get_object(b, #x)))){ \ fputs("Error: Couldn't get Gtk Widget \"" #x "\", bailing\n", stderr); \ return 1; \ } GET_WIDGET(btnSend); GET_WIDGET(btnConnect); GET_WIDGET(btnListen); GET_WIDGET(btnClose); /*GET_WIDGET(btnFileChoice);*/ GET_WIDGET(winMain); GET_WIDGET(progressft); GET_WIDGET(lblStatus); GET_WIDGET(btnOpenFolder); GET_WIDGET(btnClearTransfers); GET_WIDGET(btnDirChoice); GET_WIDGET(chkTray); GET_WIDGET(frmSend); GET_WIDGET2(hbox, "hboxHost"); /* create one with text as the column stuff */ cboHost = gtk_combo_box_entry_new_text(); gtk_container_add(GTK_CONTAINER(hbox), cboHost); gtk_widget_set_visible(cboHost, TRUE); /*gtk_box_reorder_child(GTK_BOX(hbox), cboHost, 0);*/ g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(cboHost))), "activate", G_CALLBACK(on_btnConnect_clicked), NULL); #define SCROLL_DO(scroll, tree, norder) \ scroll = gtk_scrolled_window_new(NULL, NULL); \ tree = gtk_tree_view_new(); \ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll), GTK_SHADOW_NONE); \ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); \ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE); \ gtk_container_add(GTK_CONTAINER(scroll), tree); \ gtk_box_pack_start(GTK_BOX(hbox), scroll, TRUE, TRUE, 1); /* expand, fill */ \ gtk_box_reorder_child(GTK_BOX(hbox), scroll, norder) GET_WIDGET2(hbox, "vboxSend"); SCROLL_DO(scrollQueue, treeTransfers, 1); GET_WIDGET2(hbox, "vboxConnect"); SCROLL_DO(scrollDone, treeDone, 3); g_signal_connect(G_OBJECT(treeDone), "row_activated", G_CALLBACK(on_treeDone_row_activated), NULL); #ifdef CFG_USE_RADIO # define DO_RADIO_APPEND(rad, lbl) \ rad = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(opt_Prompt), lbl); \ gtk_container_add(GTK_CONTAINER(hbox), rad) GET_WIDGET2(hbox, "vboxExistsLeft"); opt_Prompt = gtk_radio_button_new_with_label(NULL, "Prompt"); gtk_container_add(GTK_CONTAINER(hbox), opt_Prompt); DO_RADIO_APPEND(opt_Resume, "Resume"); DO_RADIO_APPEND(opt_Overwrite, "Overwrite"); GET_WIDGET2(hbox, "vboxExistsRight"); DO_RADIO_APPEND(opt_AutoRename, "Auto-Rename"); DO_RADIO_APPEND(opt_ManRename, "Manual-Rename"); # undef DO_RADIO_APPEND #else { GtkWidget *menu_header_exists, *menu_header_settings; GtkWidget *menubar, *menu_exists, *menu_settings; GSList *group = NULL; menubar = gtk_menu_bar_new(); hbox = gtk_vbox_new(FALSE, 0); #define DO_MENU(v, prev, lbl) \ opt_ ## v = gtk_radio_menu_item_new_with_label(group, lbl); \ group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(opt_ ## v)); \ gtk_menu_shell_append(GTK_MENU_SHELL(menu_exists), opt_ ## v) menu_exists = gtk_menu_new(); menu_settings = gtk_menu_new(); /* append all to menu_header_exists */ DO_MENU(Prompt, NULL, "Prompt"); DO_MENU(AutoRename, opt_Prompt, "Auto-Rename"); DO_MENU(ManRename, opt_AutoRename, "Manual-Rename"); DO_MENU(Resume, opt_ManRename, "Resume"); DO_MENU(Overwrite, opt_Resume, "Overwrite"); chkTray = gtk_check_menu_item_new_with_label("Close to tray"); { /* remove frmCfg */ GtkWidget *frmCfg, *vboxLeft; GET_WIDGET(frmCfg); GET_WIDGET(vboxLeft); gtk_container_remove(GTK_CONTAINER(vboxLeft), frmCfg); } { /* add menubar to main window */ GtkWidget *oldboxmain; GET_WIDGET2(oldboxmain, "hboxMain"); gtk_container_remove(GTK_CONTAINER(winMain), oldboxmain); gtk_container_add( GTK_CONTAINER(hbox), menubar); gtk_container_add( GTK_CONTAINER(hbox), oldboxmain); gtk_container_add(GTK_CONTAINER(winMain), hbox); gtk_box_set_child_packing(GTK_BOX(hbox), menubar, FALSE, /* expand */ TRUE, /* fill */ 0, /* padding */ GTK_PACK_START); } menu_header_settings = gtk_menu_item_new_with_label("Settings"); menu_header_exists = gtk_menu_item_new_with_label("File Exists Action"); gtk_menu_item_set_submenu(GTK_MENU_ITEM( menu_header_exists), menu_exists); gtk_menu_shell_append( GTK_MENU_SHELL(menu_settings), menu_header_exists); gtk_menu_shell_append( GTK_MENU_SHELL(menu_settings), chkTray); gtk_menu_item_set_submenu(GTK_MENU_ITEM( menu_header_settings), menu_settings); gtk_menu_shell_append( GTK_MENU_SHELL(menubar), menu_header_settings); gtk_widget_show_all(menubar); } #endif return 0; #undef GET_WIDGET #undef GET_WIDGET2 #undef SCROLL_DO }
Client * newclient(void) { Client *c; WebKitWebSettings *settings; gchar *uri; if(!(c = calloc(1, sizeof(Client)))) die("Cannot malloc!\n"); /* Window */ if(embed) { c->win = gtk_plug_new(embed); } else { c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf"); } gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600); g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c); g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c); /* VBox */ c->vbox = gtk_vbox_new(FALSE, 0); /* scrolled window */ c->scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); /* webview */ c->view = WEBKIT_WEB_VIEW(webkit_web_view_new()); g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c); g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c); g_signal_connect(G_OBJECT(c->view), "load-finished", G_CALLBACK(loadfinished), c); g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c); g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c); g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c); g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(newwindow), c); g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c); g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c); g_signal_connect_after(session, "request-started", G_CALLBACK(request), c); /* urlbar */ c->urlbar = gtk_entry_new(); gtk_entry_set_has_frame(GTK_ENTRY(c->urlbar), FALSE); g_signal_connect(G_OBJECT(c->urlbar), "focus-out-event", G_CALLBACK(unfocusbar), c); /* searchbar */ c->searchbar = gtk_entry_new(); gtk_entry_set_has_frame(GTK_ENTRY(c->searchbar), FALSE); g_signal_connect(G_OBJECT(c->searchbar), "focus-out-event", G_CALLBACK(unfocusbar), c); /* indicator */ c->indicator = gtk_drawing_area_new(); gtk_widget_set_size_request(c->indicator, 0, 2); g_signal_connect (G_OBJECT (c->indicator), "expose_event", G_CALLBACK (exposeindicator), c); /* Arranging */ gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view)); gtk_container_add(GTK_CONTAINER(c->win), c->vbox); gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll); gtk_container_add(GTK_CONTAINER(c->vbox), c->searchbar); gtk_container_add(GTK_CONTAINER(c->vbox), c->urlbar); gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator); /* Setup */ gtk_box_set_child_packing(GTK_BOX(c->vbox), c->urlbar, FALSE, FALSE, 0, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(c->vbox), c->searchbar, FALSE, FALSE, 0, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START); gtk_widget_grab_focus(GTK_WIDGET(c->view)); gtk_widget_hide_all(c->searchbar); gtk_widget_hide_all(c->urlbar); gtk_widget_show(c->vbox); gtk_widget_show(c->indicator); gtk_widget_show(c->scroll); gtk_widget_show(GTK_WIDGET(c->view)); gtk_widget_show(c->win); gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK); gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c); webkit_web_view_set_full_content_zoom(c->view, TRUE); settings = webkit_web_view_get_settings(c->view); g_object_set(G_OBJECT(settings), "user-agent", "surf", NULL); uri = g_strconcat("file://", stylefile, NULL); g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL); g_free(uri); c->download = NULL; c->title = NULL; c->next = clients; clients = c; if(showxid) { gdk_display_sync(gtk_widget_get_display(c->win)); printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); fflush(NULL); } return c; }
static void nemo_status_bar_constructed (GObject *object) { NemoStatusBar *bar = NEMO_STATUS_BAR (object); G_OBJECT_CLASS (nemo_status_bar_parent_class)->constructed (object); GtkToolbar *toolbar; GtkWidget *widget_box; GtkToolItem *item; GtkWidget *statusbar = gtk_statusbar_new (); GtkActionGroup *action_group; GtkStyleContext *context; bar->real_statusbar = statusbar; GtkIconSize size = gtk_icon_size_from_name (NEMO_STATUSBAR_ICON_SIZE_NAME); context = gtk_widget_get_style_context (GTK_WIDGET (bar)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLBAR); gtk_container_set_border_width (GTK_CONTAINER (bar), 1); GtkWidget *button, *icon; button = gtk_toggle_button_new (); icon = gtk_image_new_from_icon_name ("sidebar-places-symbolic", size); gtk_button_set_image (GTK_BUTTON (button), icon); gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Places")); bar->places_button = button; gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2); g_signal_connect (GTK_BUTTON (button), "clicked", G_CALLBACK (action_places_toggle_callback), bar); button = gtk_toggle_button_new (); icon = gtk_image_new_from_icon_name ("sidebar-tree-symbolic", size); gtk_button_set_image (GTK_BUTTON (button), icon); gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Treeview")); bar->tree_button = button; gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2); g_signal_connect (GTK_BUTTON (button), "clicked", G_CALLBACK (action_treeview_toggle_callback), bar); GtkWidget *sep = gtk_separator_new (GTK_ORIENTATION_VERTICAL); gtk_box_pack_start (GTK_BOX (bar), sep, FALSE, FALSE, 6); gtk_widget_show (sep); bar->separator = sep; button = gtk_button_new (); icon = gtk_image_new_from_icon_name ("sidebar-hide-symbolic", size); gtk_button_set_image (GTK_BUTTON (button), icon); gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Hide the Sidebar (F9)")); bar->hide_button = button; gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2); g_signal_connect (GTK_BUTTON (button), "clicked", G_CALLBACK (action_hide_sidebar_callback), bar); button = gtk_button_new (); icon = gtk_image_new_from_icon_name ("sidebar-show-symbolic", size); gtk_button_set_image (GTK_BUTTON (button), icon); gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show the Sidebar (F9)")); bar->show_button = button; gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2); g_signal_connect (GTK_BUTTON (button), "clicked", G_CALLBACK (action_show_sidebar_callback), bar); gtk_box_pack_start (GTK_BOX (bar), statusbar, TRUE, TRUE, 10); GtkWidget *zoom_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 6.0, 1.0); gtk_widget_set_tooltip_text (GTK_WIDGET (zoom_slider), _("Adjust zoom level")); bar->zoom_slider = zoom_slider; gtk_box_pack_start (GTK_BOX (bar), zoom_slider, FALSE, FALSE, 2); gtk_widget_set_size_request (GTK_WIDGET (zoom_slider), SLIDER_WIDTH, 0); gtk_scale_set_draw_value (GTK_SCALE (zoom_slider), FALSE); gtk_range_set_increments (GTK_RANGE (zoom_slider), 1.0, 1.0); gtk_range_set_round_digits (GTK_RANGE (zoom_slider), 0); gtk_widget_show_all (GTK_WIDGET (bar)); g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-sidebar", G_CALLBACK (sidebar_state_changed_cb), bar, G_CONNECT_AFTER); g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::sidebar-view-id", G_CALLBACK (sidebar_type_changed_cb), bar, G_CONNECT_AFTER); g_signal_connect (GTK_RANGE (zoom_slider), "value-changed", G_CALLBACK (on_slider_changed_cb), bar); GtkWidget *cont = gtk_statusbar_get_message_area (GTK_STATUSBAR (statusbar)); GList *children = gtk_container_get_children (GTK_CONTAINER (cont)); gtk_box_set_child_packing (GTK_BOX (cont), GTK_WIDGET (children->data), TRUE, FALSE, 10, GTK_PACK_START); nemo_status_bar_sync_button_states (bar); }