static GtkWidget* pocketvox_setup_get_notification_grid(PocketvoxSetup *setup) { setup->priv = G_TYPE_INSTANCE_GET_PRIVATE (setup, TYPE_POCKETVOX_SETUP, PocketvoxSetupPrivate); PocketvoxSetupPrivate *priv = setup->priv; GtkWidget *grid = gtk_grid_new(); GtkWidget *label_visual = gtk_label_new(_("Allow visual notifications")); GtkWidget *label_sound = gtk_label_new(_("Allow sound notifications")); gtk_misc_set_alignment(GTK_MISC(label_visual), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(label_sound), 0.0, 0.5); gtk_widget_set_hexpand(label_visual, TRUE); gtk_widget_set_hexpand(label_sound, TRUE); GtkWidget* switch_sound = gtk_switch_new(); GtkWidget* switch_visual = gtk_switch_new(); gtk_widget_set_tooltip_text(switch_sound, _("Allow sound notifications")); gtk_widget_set_tooltip_text(switch_visual, _("Allow visual notifications")); g_settings_bind(priv->settings, "visual-notification", switch_visual, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind(priv->settings, "sound-notification", switch_sound, "active", G_SETTINGS_BIND_DEFAULT); gtk_grid_attach(GTK_GRID(grid), label_visual, 0, 2, 2, 1); gtk_grid_attach(GTK_GRID(grid), switch_visual, 2, 2, 1, 1); gtk_grid_attach(GTK_GRID(grid), label_sound, 0, 3, 2, 1); gtk_grid_attach(GTK_GRID(grid), switch_sound, 2, 3, 1, 1); gtk_widget_show_all(grid); return grid; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *box; GtkWidget *bu; GtkWidget *w, *c; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_container_add (GTK_CONTAINER (window), box); w = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15); gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (w), gtk_entry_new (), TRUE, TRUE, 0); bu = gtk_button_new_with_label ("Bu"); gtk_box_pack_start (GTK_BOX (w), bu, TRUE, TRUE, 0); c = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (c), TRUE); gtk_widget_set_halign (c, GTK_ALIGN_CENTER); gtk_widget_set_valign (c, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), c, TRUE, TRUE, 0); g_signal_connect (bu, "clicked", G_CALLBACK (set_insensitive), w); g_signal_connect (bu, "state-changed", G_CALLBACK (state_changed), NULL); g_object_bind_property (c, "active", w, "sensitive", G_BINDING_BIDIRECTIONAL); gtk_widget_show_all (window); gtk_main (); return 0; }
static void cc_search_panel_constructed (GObject *object) { CcSearchPanel *self = CC_SEARCH_PANEL (object); GtkWidget *box, *widget, *search_box; G_OBJECT_CLASS (cc_search_panel_parent_class)->constructed (object); /* add the disable all switch */ search_box = WID ("search_vbox"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); widget = gtk_switch_new (); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 4); g_settings_bind (self->priv->search_settings, "disable-external", widget, "active", G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN); g_object_bind_property (widget, "active", search_box, "sensitive", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); gtk_widget_show_all (box); cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (self)), box); }
static GtkWidget * nimf_settings_page_key_build_boolean (NimfSettingsPageKey *page_key) { GtkWidget *gswitch; GtkWidget *hbox; gchar *detailed_signal; gboolean is_active; gswitch = gtk_switch_new (); is_active = g_settings_get_boolean (page_key->gsettings, page_key->key); gtk_switch_set_active (GTK_SWITCH (gswitch), is_active); gtk_widget_set_halign (gswitch, GTK_ALIGN_END); detailed_signal = g_strdup_printf ("changed::%s", page_key->key); g_signal_connect (gswitch, "notify::active", G_CALLBACK (on_notify_active), page_key); g_signal_connect (page_key->gsettings, detailed_signal, G_CALLBACK (on_gsettings_changed), gswitch); g_free (detailed_signal); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 15); gtk_box_pack_start (GTK_BOX (hbox), page_key->label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), gswitch, FALSE, FALSE, 0); return hbox; }
static GtkWidget* main_window() { GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Cheeseburger Machine"); gtk_container_set_border_width(GTK_CONTAINER(window), 10); GtkWidget* listbox = gtk_list_box_new(); gtk_list_box_set_selection_mode(GTK_LIST_BOX(listbox), GTK_SELECTION_NONE); gtk_container_add(GTK_CONTAINER(window), listbox); // Re-use variables so we're not making row1, row2, and such. GtkWidget *row, *box, *label; // Checkbox row = gtk_list_box_row_new(); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 100); gtk_container_add(GTK_CONTAINER(row), box); label = gtk_label_new("Check if you love cheeseburgers:"); GtkWidget* check = gtk_check_button_new(); gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(box), check, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(listbox), row); // Toggle Switch row = gtk_list_box_row_new(); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 100); gtk_container_add(GTK_CONTAINER(row), box); label = gtk_label_new("Burger making machine`:"); GtkWidget* switcher = gtk_switch_new(); gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(box), switcher, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(listbox), row); return window; }
static GtkWidget * make_switch (gboolean is_on, gboolean is_sensitive) { GtkWidget *hbox; GtkWidget *sw, *label; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); sw = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (sw), is_on); gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0); gtk_widget_set_sensitive (sw, is_sensitive); gtk_widget_show (sw); label = gtk_label_new (is_on ? "Enabled" : "Disabled"); gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0); gtk_widget_show (label); g_object_bind_property_full (sw, "active", label, "label", G_BINDING_DEFAULT, boolean_to_text, NULL, NULL, NULL); return hbox; }
static WidgetInfo * create_switch (void) { GtkWidget *widget; GtkWidget *sw; widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3); sw = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (sw), TRUE); gtk_container_add (GTK_CONTAINER (widget), sw); sw = gtk_switch_new (); gtk_container_add (GTK_CONTAINER (widget), sw); gtk_widget_set_halign (widget, GTK_ALIGN_CENTER); gtk_widget_set_valign (widget, GTK_ALIGN_CENTER); return new_widget_info ("switch", widget, SMALL); }
static void place_query_info_ready (GObject *source, GAsyncResult *res, gpointer user_data) { GtkWidget *row, *box, *w; Place *place; GFileInfo *info; const gchar *desktop_path; gchar *path; info = g_file_query_info_finish (G_FILE (source), res, NULL); if (!info) return; row = user_data; place = g_object_get_data (G_OBJECT (row), "place"); g_clear_object (&place->cancellable); box = gtk_bin_get_child (GTK_BIN (row)); /* FIXME: GLib is currently buggy and returns a non-existent icon name * when asked for the desktop symbolic icon. */ desktop_path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); path = g_file_get_path (G_FILE (source)); if (g_strcmp0 (path, desktop_path) == 0) place->icon = g_themed_icon_new ("folder-symbolic"); else place->icon = g_object_ref (g_file_info_get_symbolic_icon (info)); if (g_strcmp0 (path, g_get_home_dir ()) == 0) place->settings_key = TRACKER_KEY_SINGLE_DIRECTORIES; else place->settings_key = TRACKER_KEY_RECURSIVE_DIRECTORIES; g_free (path); w = gtk_image_new_from_gicon (place->icon, GTK_ICON_SIZE_MENU); gtk_container_add (GTK_CONTAINER (box), w); w = gtk_label_new (place->display_name); gtk_container_add (GTK_CONTAINER (box), w); w = gtk_switch_new (); gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0); g_settings_bind_with_mapping (tracker_preferences, place->settings_key, w, "active", G_SETTINGS_BIND_DEFAULT, switch_tracker_get_mapping, switch_tracker_set_mapping, place, NULL); gtk_widget_show_all (row); g_object_unref (info); }
static void cc_wacom_mapping_panel_init (CcWacomMappingPanel *self) { CcWacomMappingPanelPrivate *priv; GtkWidget *vbox, *grid; GtkCellRenderer *renderer; priv = self->priv = WACOM_MAPPING_PANEL_PRIVATE (self); vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); gtk_container_add (GTK_CONTAINER (self), vbox); gtk_container_set_border_width (GTK_CONTAINER (self), 12); gtk_widget_set_vexpand (GTK_WIDGET (vbox), TRUE); gtk_widget_set_hexpand (GTK_WIDGET (vbox), TRUE); /* Output Combobox */ grid = gtk_grid_new(); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); priv->label = gtk_label_new (_("Output:")); gtk_widget_set_halign (priv->label, GTK_ALIGN_END); priv->combobox = gtk_combo_box_new (); g_signal_connect (G_OBJECT (priv->combobox), "changed", G_CALLBACK (combobox_changed_cb), self); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(priv->combobox), renderer, TRUE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(priv->combobox), renderer, "text", 0); gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->label), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->combobox), 1, 0, 1, 1); /* Keep ratio switch */ priv->aspectlabel = gtk_label_new (_("Keep aspect ratio (letterbox):")); gtk_widget_set_halign (priv->aspectlabel, GTK_ALIGN_END); priv->aspectswitch = gtk_switch_new (); gtk_widget_set_halign (priv->aspectswitch, GTK_ALIGN_START); gtk_switch_set_active (GTK_SWITCH (priv->aspectswitch), FALSE); g_signal_connect (GTK_SWITCH (priv->aspectswitch), "notify::active", G_CALLBACK (aspectswitch_toggled_cb), self); gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectlabel), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectswitch), 1, 1, 1, 1); /* Whole-desktop checkbox */ priv->checkbutton = gtk_check_button_new_with_label (_("Map to single monitor")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton), FALSE); g_signal_connect (G_OBJECT (priv->checkbutton), "toggled", G_CALLBACK (checkbutton_toggled_cb), self); gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(priv->checkbutton), FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(grid), FALSE, FALSE, 8); /* Update display */ cc_wacom_mapping_panel_set_device (self, NULL); gtk_widget_show_all(GTK_WIDGET(self)); }
static GtkWidget * garu_effects_init_box_crossfade (GaruEffects *self) { gchar *text; GtkWidget *vbox, *hbox, *label, *toogle, *check_button, *spin_button; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_container_set_border_width (GTK_CONTAINER (vbox), 10); /* Label enabled */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); label = gtk_label_new (NULL); text = garu_utils_text_bold (_("Enabled")); gtk_label_set_markup (GTK_LABEL (label), text); g_free (text); gtk_widget_set_halign (label, GTK_ALIGN_START); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); toogle = gtk_switch_new (); g_settings_bind (self->settings, "crossfade-enabled", toogle, "active", G_SETTINGS_BIND_DEFAULT); gtk_box_pack_start (GTK_BOX (hbox), toogle, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); /* Spin button */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); label = gtk_label_new (_("Crossfade duration in seconds")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); spin_button = gtk_spin_button_new_with_range (1, 12, 1.0); g_settings_bind (self->settings, "crossfade-time", spin_button, "value", G_SETTINGS_BIND_DEFAULT); gtk_box_pack_start (GTK_BOX (hbox), spin_button, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); g_settings_bind (self->settings, "crossfade-enabled", hbox, "sensitive", G_SETTINGS_BIND_GET); /* Check buttons options */ text = g_strdup (_("Crossfade when the user change the track")); check_button = gtk_check_button_new_with_label (text); g_free (text); gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 0); g_settings_bind (self->settings, "crossfade-change-track", check_button, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (self->settings, "crossfade-enabled", check_button, "sensitive", G_SETTINGS_BIND_GET); text = g_strdup (_("Crossfade before the track ends")); check_button = gtk_check_button_new_with_label (text); g_free (text); gtk_box_pack_start (GTK_BOX (vbox), check_button, FALSE, FALSE, 0); g_settings_bind (self->settings, "crossfade-track-ends", check_button, "active", G_SETTINGS_BIND_DEFAULT); g_settings_bind (self->settings, "crossfade-enabled", check_button, "sensitive", G_SETTINGS_BIND_GET); return vbox; }
static WidgetInfo * create_switch (void) { GtkWidget *widget; GtkWidget *align; GtkWidget *sw; widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3); sw = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (sw), TRUE); gtk_box_pack_start (GTK_BOX (widget), sw, TRUE, TRUE, 0); sw = gtk_switch_new (); gtk_box_pack_start (GTK_BOX (widget), sw, TRUE, TRUE, 0); align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); gtk_container_add (GTK_CONTAINER (align), widget); return new_widget_info ("switch", align, SMALL); }
/* When the user clicks the Add button, add a random widget to the PSquare */ static void add_clicked(GtkToolButton *button, GtkWidget *square) { GList *children; GtkWidget *widget; int count; char *text; /* Get the number of this new widget and print it in a string */ children = gtk_container_get_children(GTK_CONTAINER(square)); count = g_list_length(children) + 1; g_list_free(children); text = g_strdup_printf("Widget #%d", count); /* Pick a widget and put the text in it if possible */ switch(g_random_int_range(0, 8)) { case 0: widget = gtk_image_new_from_stock(GTK_STOCK_NEW, g_random_int_range(1, 6)); break; case 1: widget = gtk_label_new(text); break; case 2: widget = gtk_button_new_with_label(text); break; case 3: widget = gtk_check_button_new_with_label(text); break; case 4: widget = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(widget), text); break; case 5: widget = gtk_spin_button_new_with_range(0.0, (double)count, 1.0); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), (double)count); break; case 6: widget = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text); gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0); break; case 7: widget = gtk_switch_new(); break; } g_free(text); /* Show the widget and add it to our container */ gtk_widget_show(widget); gtk_container_add(GTK_CONTAINER(square), widget); }
/* flashlight_new */ Flashlight * flashlight_new(GtkOrientation orientation) { Flashlight * flashlight; GtkWidget * widget; GtkIconTheme * icontheme; GdkPixbuf * pixbuf; const unsigned int size = 256; const unsigned int flags = 0; if((flashlight = object_new(sizeof(*flashlight))) == NULL) return NULL; flashlight->box = gtk_box_new(orientation, 0); gtk_box_set_homogeneous(GTK_BOX(flashlight->box), TRUE); /* image */ icontheme = gtk_icon_theme_get_default(); pixbuf = gtk_icon_theme_load_icon(icontheme, "gtk-dialog-info", size, flags, NULL); flashlight->image = gtk_image_new_from_pixbuf(pixbuf); gtk_box_pack_start(GTK_BOX(flashlight->box), flashlight->image, TRUE, TRUE, 0); /* controls */ widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); /* press switch */ flashlight->co_press = gtk_button_new_with_mnemonic(_("_Press")); g_signal_connect_swapped(flashlight->co_press, "button-press-event", G_CALLBACK(_flashlight_on_button_pressed), flashlight); g_signal_connect_swapped(flashlight->co_press, "button-release-event", G_CALLBACK(_flashlight_on_button_released), flashlight); gtk_widget_set_no_show_all(flashlight->co_press, TRUE); gtk_box_pack_start(GTK_BOX(widget), flashlight->co_press, TRUE, TRUE, 0); /* toggle switch */ #if GTK_CHECK_VERSION(3, 0, 0) flashlight->co_toggle = gtk_switch_new(); g_signal_connect_swapped(flashlight->co_toggle, "notify::active", G_CALLBACK(_flashlight_on_toggled), flashlight); #else # warning Switch widget is not available (needs Gtk+ >= 3.0) flashlight->co_toggle = gtk_toggle_button_new_with_mnemonic( _("_Switch")); g_signal_connect_swapped(flashlight->co_toggle, "toggled", G_CALLBACK( _flashlight_on_toggled), flashlight); #endif gtk_widget_set_no_show_all(flashlight->co_toggle, TRUE); gtk_box_pack_start(GTK_BOX(widget), flashlight->co_toggle, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(flashlight->box), widget, FALSE, TRUE, 0); flashlight_set_active(flashlight, flashlight_get_active(flashlight)); flashlight_set_keep_lit(flashlight, TRUE); return flashlight; }
static void populate_flowbox_focus (GtkFlowBox *flowbox) { GtkWidget *widget, *frame, *box; gint i; gboolean sensitive; for (i = 0; i < 200; i++) { sensitive = TRUE; frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (frame), box); widget = gtk_label_new ("Label"); gtk_container_add (GTK_CONTAINER (box), widget); switch (i % 4) { case 0: widget = gtk_entry_new (); break; case 1: widget = gtk_button_new_with_label ("Button"); break; case 2: widget = gtk_label_new ("bla"); break; case 3: widget = gtk_label_new ("bla"); sensitive = FALSE; break; } gtk_container_add (GTK_CONTAINER (box), widget); if (i % 5 == 0) gtk_container_add (GTK_CONTAINER (box), gtk_switch_new ()); gtk_widget_show_all (frame); gtk_container_add (GTK_CONTAINER (flowbox), frame); if (!sensitive) gtk_widget_set_sensitive (gtk_widget_get_parent (frame), FALSE); } }
static void gtk_technology_init(GtkTechnology *technology) { GtkTechnologyPrivate *priv; priv = G_TYPE_INSTANCE_GET_PRIVATE(technology, GTK_TYPE_TECHNOLOGY, GtkTechnologyPrivate); technology->priv = priv; priv->box = (GtkBox *) gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); priv->enabler = (GtkSwitch *) gtk_switch_new(); priv->name = (GtkLabel *) gtk_label_new(NULL); gtk_widget_set_margin_left((GtkWidget *)priv->enabler, 0); gtk_widget_set_margin_right((GtkWidget *)priv->enabler, 0); gtk_widget_set_margin_top((GtkWidget *)priv->enabler, 0); gtk_widget_set_margin_bottom((GtkWidget *)priv->enabler, 0); gtk_widget_set_margin_left((GtkWidget *)priv->name, 0); gtk_widget_set_margin_right((GtkWidget *)priv->name, 0); gtk_widget_set_margin_top((GtkWidget *)priv->name, 0); gtk_widget_set_margin_bottom((GtkWidget *)priv->name, 0); gtk_box_set_spacing(priv->box, 0); gtk_box_set_homogeneous(priv->box, TRUE); //gtk_widget_set_halign((GtkWidget *)priv->box, GTK_ALIGN_START); gtk_widget_set_halign((GtkWidget *)priv->name, GTK_ALIGN_START); //gtk_widget_set_halign((GtkWidget *)technology, GTK_ALIGN_START); gtk_box_pack_start(priv->box, (GtkWidget *)priv->enabler, FALSE, FALSE, 0); gtk_box_pack_start(priv->box, (GtkWidget *)priv->name, FALSE, FALSE, 0); gtk_widget_set_visible((GtkWidget *)priv->box, TRUE); gtk_widget_set_visible((GtkWidget *)priv->enabler, TRUE); gtk_widget_set_visible((GtkWidget *)priv->name, TRUE); gtk_container_add(GTK_CONTAINER(technology), (GtkWidget *)priv->box); gtk_widget_set_can_focus((GtkWidget *)priv->box, TRUE); gtk_widget_set_can_focus((GtkWidget *)priv->enabler, TRUE); }
static GtkWidget * make_delayed_switch (gboolean is_on, gboolean is_sensitive) { GtkWidget *hbox; GtkWidget *sw, *label, *spinner, *check; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); sw = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (sw), is_on); gtk_box_pack_start (GTK_BOX (hbox), sw, FALSE, FALSE, 0); gtk_widget_set_sensitive (sw, is_sensitive); gtk_widget_show (sw); g_signal_connect (sw, "state-set", G_CALLBACK (set_state), NULL); spinner = gtk_spinner_new (); gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, TRUE, 0); gtk_widget_set_opacity (spinner, 0.0); gtk_widget_show (spinner); check = gtk_check_button_new (); gtk_box_pack_end (GTK_BOX (hbox), check, FALSE, TRUE, 0); gtk_widget_show (check); g_object_bind_property (sw, "state", check, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); label = gtk_label_new (is_on ? "Enabled" : "Disabled"); gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 0); gtk_widget_show (label); g_object_bind_property_full (sw, "active", label, "label", G_BINDING_DEFAULT, boolean_to_text, NULL, NULL, NULL); g_signal_connect (sw, "notify", G_CALLBACK (sw_delay_notify), spinner); return hbox; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *box; GtkWidget *bar; GtkWidget *box2; GtkWidget *sw; gtk_init (&argc, &argv); add_custom_css (); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 500, 100); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); g_object_set (box, "margin", 20, NULL); bar = create_level_bar (); gtk_container_add (GTK_CONTAINER (window), box); gtk_container_add (GTK_CONTAINER (box), bar); box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_add (GTK_CONTAINER (box), box2); gtk_container_add (GTK_CONTAINER (box2), gtk_label_new ("Discrete")); sw = gtk_switch_new (); gtk_container_add (GTK_CONTAINER (box2), sw); g_signal_connect (sw, "notify::active", G_CALLBACK (toggle), bar); gtk_widget_show_all (window); g_signal_connect (window, "delete-event", G_CALLBACK (window_delete_event), NULL); g_timeout_add (100, increase_level, bar); gtk_main (); return 0; }
JNIEXPORT jlong JNICALL Java_org_gnome_gtk_GtkSwitch_gtk_1switch_1new ( JNIEnv* env, jclass cls ) { GtkWidget* result; jlong _result; // call function result = gtk_switch_new(); // translate return value to JNI type _result = (jlong) result; // cleanup return value if (result != NULL) { bindings_java_memory_cleanup((GObject*)result, TRUE); } // and finally return _result; }
static GtkWidget * create_extensions_row (GthExtensionDescription *description, BrowserData *browser_data) { GtkWidget *row; GtkWidget *row_box; RowData *row_data; GtkWidget *button; GtkWidget *label_box; GtkWidget *label; GthExtension *extension; row = gtk_list_box_row_new (); row_data = row_data_new (browser_data, description); g_object_set_data_full (G_OBJECT (row), "extension-row-data", row_data, (GDestroyNotify) row_data_free); row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_set_border_width (GTK_CONTAINER (row_box), 10); gtk_container_add (GTK_CONTAINER (row), row_box); button = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (button), gth_extension_description_is_active (description)); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "notify::active", G_CALLBACK (extension_switch_activated_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 3); label_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); label = gtk_label_new (description->name); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_style_context_add_class (gtk_widget_get_style_context (label), "extension-name"); gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, FALSE, 0); label = gtk_label_new (description->description); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_style_context_add_class (gtk_widget_get_style_context (label), "extension-description"); gtk_box_pack_start (GTK_BOX (label_box), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (row_box), label_box, TRUE, TRUE, 3); extension = gth_extension_description_get_extension (description); if ((extension != NULL) && gth_extension_is_configurable (extension)) { button = gtk_button_new_from_icon_name ("emblem-system-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_tooltip_text (button, _("Preferences")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "clicked", G_CALLBACK (extension_preferences_button_clicked_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 0); } if ((extension != NULL) && (g_strcmp0 (description->authors[0], _("gthumb development team")) != 0)) { button = gtk_button_new_from_icon_name ("dialog-information-symbolic", GTK_ICON_SIZE_BUTTON); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); g_signal_connect (button, "clicked", G_CALLBACK (extension_information_button_clicked_cb), row_data); gtk_box_pack_start (GTK_BOX (row_box), button, FALSE, FALSE, 0); } gtk_widget_show_all (row); return row; }
static void search_panel_add_one_app_info (CcSearchPanel *self, GAppInfo *app_info, gboolean default_enabled) { GtkWidget *row, *box, *w; GIcon *icon; /* gnome-control-center is special cased in the shell, and is not configurable */ if (g_strcmp0 (g_app_info_get_id (app_info), "gnome-control-center.desktop") == 0) return; /* reset valignment of the list box */ gtk_widget_set_valign (self->priv->list_box, GTK_ALIGN_FILL); row = gtk_list_box_row_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (row), box); gtk_widget_set_hexpand (box, TRUE); gtk_container_set_border_width (GTK_CONTAINER (box), 6); g_object_set_data_full (G_OBJECT (row), "app-info", g_object_ref (app_info), g_object_unref); g_object_set_data (G_OBJECT (row), "self", self); gtk_container_add (GTK_CONTAINER (self->priv->list_box), row); icon = g_app_info_get_icon (app_info); if (icon == NULL) icon = g_themed_icon_new ("application-x-executable"); else g_object_ref (icon); w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG); gtk_container_add (GTK_CONTAINER (box), w); g_object_unref (icon); w = gtk_label_new (g_app_info_get_name (app_info)); gtk_container_add (GTK_CONTAINER (box), w); w = gtk_switch_new (); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0); if (default_enabled) { g_settings_bind_with_mapping (self->priv->search_settings, "disabled", w, "active", G_SETTINGS_BIND_DEFAULT, switch_settings_mapping_get_default_enabled, switch_settings_mapping_set_default_enabled, row, NULL); } else { g_settings_bind_with_mapping (self->priv->search_settings, "enabled", w, "active", G_SETTINGS_BIND_DEFAULT, switch_settings_mapping_get_default_disabled, switch_settings_mapping_set_default_disabled, row, NULL); } gtk_widget_show_all (row); }
int main(int argc, char **argv) { GtkWidget *window; GtkWidget *pVBox; GtkWidget *pMenuBar; GtkWidget *pMenu; GtkWidget *pMenuItem; GtkWidget *grid; GtkWidget *label; GtkWidget *switcher; gtk_init(&argc, &argv); /* création de la fenetre */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position (GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_title (GTK_WINDOW (window), "Telecommande-Pcduino"); gtk_container_set_border_width (GTK_CONTAINER (window), 10); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); /* Création de la GtkVBox */ pVBox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), pVBox); // ---------------------------------------------------------------------------------- /**** Création du menu ****/ /* ETAPE 1 */ pMenuBar = gtk_menu_bar_new(); /** Premier sous-menu **/ /* ETAPE 2 */ pMenu = gtk_menu_new(); /* ETAPE 3 */ pMenuItem = gtk_menu_item_new_with_label("Mode On/Off"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(OnOff),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); pMenuItem = gtk_menu_item_new_with_label("Mode Impulsion"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(Impulse),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); pMenuItem = gtk_menu_item_new_with_label("Modifier le nom des Gpio"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(ChangeName),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); pMenuItem = gtk_menu_item_new_with_label("Initialisation des Gpio en output"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(InitGpio),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); pMenuItem = gtk_menu_item_new_with_label("Quitter"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(OnQuitter),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); /* ETAPE 4 */ pMenuItem = gtk_menu_item_new_with_label("Configuration"); /* ETAPE 5 */ gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), pMenu); /* ETAPE 6 */ gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); /** Second sous-menu **/ /* ETAPE 2 */ pMenu = gtk_menu_new(); /* ETAPE 3 */ pMenuItem = gtk_menu_item_new_with_label("Aide"); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(Aide),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); pMenuItem = gtk_menu_item_new_with_label("A propos de..."); g_signal_connect(G_OBJECT(pMenuItem), "activate", G_CALLBACK(OnAbout),(GtkWidget*) window); gtk_menu_shell_append(GTK_MENU_SHELL(pMenu), pMenuItem); /* ETAPE 4 */ pMenuItem = gtk_menu_item_new_with_label("?"); /* ETAPE 5 */ gtk_menu_item_set_submenu(GTK_MENU_ITEM(pMenuItem), pMenu); /* ETAPE 6 */ gtk_menu_shell_append(GTK_MENU_SHELL(pMenuBar), pMenuItem); /* Ajout du menu a la fenetre */ gtk_box_pack_start(GTK_BOX(pVBox), pMenuBar, FALSE, FALSE, 0); // ---------------------------------------------------------------------------------- /* construction du conteneur type grid */ grid = gtk_grid_new (); gtk_grid_set_row_homogeneous (GTK_GRID (grid), TRUE); gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); /* Placement du conteneur dans la fenetre */ gtk_box_pack_start(GTK_BOX(pVBox), grid, FALSE, FALSE, 0); // --------------------------------------------------------------------- /*Creer un label*/ label = gtk_label_new ("Gpio 0"); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); /*Creer un switch avec pour valeur de defaut desactive*/ switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); /*placement du switch*/ gtk_grid_attach (GTK_GRID (grid), switcher, 1, 0, 1, 1); /*Connecter le signal clique a la fonction de callback*/ g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb0), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 1"); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 1, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb1), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 2"); gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 2, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb2), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 3"); gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 3, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb3), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 4"); gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 4, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb4), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 5"); gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 5, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb5), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 6"); gtk_grid_attach (GTK_GRID (grid), label, 0, 6, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 6, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb6), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 7"); gtk_grid_attach (GTK_GRID (grid), label, 0, 7, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 7, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb7), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 8"); gtk_grid_attach (GTK_GRID (grid), label, 0, 8, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 8, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb8), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 9"); gtk_grid_attach (GTK_GRID (grid), label, 0, 9, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 9, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb9), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 10"); gtk_grid_attach (GTK_GRID (grid), label, 0, 10, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 10, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb10), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 11"); gtk_grid_attach (GTK_GRID (grid), label, 0, 11, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 11, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb11), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 12"); gtk_grid_attach (GTK_GRID (grid), label, 0, 12, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 12, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb12), window); // --------------------------------------------------------------------------- label = gtk_label_new ("Gpio 13"); gtk_grid_attach (GTK_GRID (grid), label, 0, 13, 1, 1); switcher = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (switcher), FALSE); gtk_grid_attach (GTK_GRID (grid), switcher, 1, 13, 1, 1); g_signal_connect (GTK_SWITCH (switcher), "notify::active", G_CALLBACK (activate_cb13), window); // --------------------------------------------------------------------------- gtk_widget_show_all(window); gtk_main(); return EXIT_SUCCESS; }
static void cc_sharing_panel_init (CcSharingPanel *self) { CcSharingPanelPrivate *priv = self->priv = PANEL_PRIVATE (self); GtkWidget *box; GError *err = NULL; gchar *objects[] = { "sharing-panel", "bluetooth-sharing-dialog", "media-sharing-dialog", "personal-file-sharing-dialog", "remote-login-dialog", "screen-sharing-dialog", NULL }; GError *error = NULL; g_resources_register (cc_sharing_get_resource ()); priv->builder = gtk_builder_new (); gtk_builder_add_objects_from_resource (priv->builder, "/org/gnome/control-center/sharing/sharing.ui", objects, &err); if (err) g_error ("Error loading CcSharingPanel user interface: %s", err->message); priv->hostname_entry = WID ("hostname-entry"); gtk_container_add (GTK_CONTAINER (self), WID ("sharing-panel")); g_signal_connect (WID ("main-list-box"), "row-activated", G_CALLBACK (cc_sharing_panel_main_list_box_row_activated), self); priv->hostname_cancellable = g_cancellable_new (); priv->bluetooth_sharing_dialog = WID ("bluetooth-sharing-dialog"); priv->media_sharing_dialog = WID ("media-sharing-dialog"); priv->personal_file_sharing_dialog = WID ("personal-file-sharing-dialog"); priv->remote_login_dialog = WID ("remote-login-dialog"); priv->remote_login_cancellable = g_cancellable_new (); priv->screen_sharing_dialog = WID ("screen-sharing-dialog"); g_signal_connect (priv->bluetooth_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (priv->media_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (priv->personal_file_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (priv->remote_login_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); g_signal_connect (priv->screen_sharing_dialog, "response", G_CALLBACK (gtk_widget_hide), NULL); gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (WID ("main-list-box")), TRUE); gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("main-list-box")), cc_list_box_update_header_func, NULL, NULL); /* create the master switch */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); priv->master_switch = gtk_switch_new (); gtk_widget_set_valign (priv->master_switch, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), priv->master_switch, FALSE, FALSE, 4); gtk_widget_show_all (box); /* start the panel in the disabled state */ gtk_switch_set_active (GTK_SWITCH (priv->master_switch), FALSE); gtk_widget_set_sensitive (WID ("main-list-box"), FALSE); g_signal_connect (priv->master_switch, "notify::active", G_CALLBACK (cc_sharing_panel_master_switch_notify), self); self->priv->sharing_proxy = G_DBUS_PROXY (gsd_sharing_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, "org.gnome.SettingsDaemon.Sharing", "/org/gnome/SettingsDaemon/Sharing", NULL, &error)); if (!self->priv->sharing_proxy) { g_warning ("Failed to get sharing proxy: %s", error->message); g_error_free (error); } /* bluetooth */ if (cc_sharing_panel_check_schema_available (self, FILE_SHARING_SCHEMA_ID)) cc_sharing_panel_setup_bluetooth_sharing_dialog (self); else gtk_widget_hide (WID ("bluetooth-sharing-button")); /* media sharing */ cc_sharing_panel_setup_media_sharing_dialog (self); /* personal file sharing */ if (cc_sharing_panel_check_schema_available (self, FILE_SHARING_SCHEMA_ID)) cc_sharing_panel_setup_personal_file_sharing_dialog (self); else gtk_widget_hide (WID ("personal-file-sharing-button")); /* remote login */ cc_sharing_panel_setup_remote_login_dialog (self); /* screen sharing */ if (cc_sharing_panel_check_schema_available (self, VINO_SCHEMA_ID)) cc_sharing_panel_setup_screen_sharing_dialog (self); else gtk_widget_hide (WID ("screen-sharing-button")); /* make sure the hostname entry isn't focused by default */ g_signal_connect_swapped (self, "map", G_CALLBACK (gtk_widget_grab_focus), WID ("main-list-box")); }
void keybinds_window_create (void) { int i; GtkWidget *vbox_kb_m, *hbox_kb_s, *hbox_kb_lay; GtkWidget *but_kb_close, *but_kb_save, *but_kb_reset; GtkWidget *lab_kb_e, *hbox_kb_bind[4], *entry_kb_test; GtkWidget *vbox_kb_s1, *vbox_kb_s2, *hbox_kb_m; win_kb_main = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(win_kb_main), "Pomf it! - Keybinds Settings"); g_signal_connect(win_kb_main, "destroy", G_CALLBACK(keybinds_window_destroy), NULL); gtk_container_set_border_width(GTK_CONTAINER(win_kb_main), 10); gtk_window_resize(GTK_WINDOW(win_kb_main), 500, 200); gtk_window_set_position(GTK_WINDOW(win_kb_main), GTK_WIN_POS_CENTER); vbox_kb_m = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0); gtk_container_add(GTK_CONTAINER(win_kb_main), vbox_kb_m); hbox_kb_m = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0); gtk_container_add(GTK_CONTAINER(vbox_kb_m), hbox_kb_m); vbox_kb_s1 = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0); gtk_container_add(GTK_CONTAINER(hbox_kb_m), vbox_kb_s1); vbox_kb_s2 = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0); gtk_container_add(GTK_CONTAINER(hbox_kb_m), vbox_kb_s2); lab_kb_e = gtk_label_new("File Upload:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Area & UP:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Window & UP:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Fullscreen & UP:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Area:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Window:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5); lab_kb_e = gtk_label_new("Capture Fullscreen:"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5); lab_kb_e = gtk_label_new("Open URL(s):"); gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5); for ( i = 0 ; i < HOTKEY_COUNT ; ++i) { hbox_kb_bind[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL ,4); gtk_container_add (GTK_CONTAINER(vbox_kb_s2),hbox_kb_bind[i]); com_kb_mod1[i] = gtk_combo_box_text_new(); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, ""); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<CTRL>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<SHIFT>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<ALT>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<WIN>"); gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_mod1[i]); com_kb_mod2[i] = gtk_combo_box_text_new(); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, ""); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<CTRL>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<SHIFT>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<ALT>"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<WIN>"); gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_mod2[i]); com_kb_key[i] = gtk_combo_box_text_new(); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "!"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "\""); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "#"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "$"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "%"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "&"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "'"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "("); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ")"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "*"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "+"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ","); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "-"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "."); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "/"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "0"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "1"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "2"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "3"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "4"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "5"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "6"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "7"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "8"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "9"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ":"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ";"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "<"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "="); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ">"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "?"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "@"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "A"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "B"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "C"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "D"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "E"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "F"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "G"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "H"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "I"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "J"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "K"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "L"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "M"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "N"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "O"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "P"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Q"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "R"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "S"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "T"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "U"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "V"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "W"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "X"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Y"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Z"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "["); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "\\"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "]"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "^"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "_"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "`"); gtk_combo_box_set_active(GTK_COMBO_BOX(com_kb_key[i]), 0); gtk_combo_box_set_wrap_width (GTK_COMBO_BOX(com_kb_key[i]), 8); gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_key[i]); sw_kb[i] = gtk_switch_new(); gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), sw_kb[i]); } keybinds_window_create_set_actives(); hbox_kb_lay = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 5); gtk_container_add(GTK_CONTAINER(vbox_kb_m), hbox_kb_lay); lab_kb_e = gtk_label_new("Wait...What's my keyboard layout again ? .."); gtk_box_pack_start (GTK_BOX(hbox_kb_lay), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5); entry_kb_test = gtk_entry_new (); gtk_container_add(GTK_CONTAINER(hbox_kb_lay), entry_kb_test); hbox_kb_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0); gtk_box_pack_end(GTK_BOX(vbox_kb_m), hbox_kb_s, FALSE, FALSE, 0); but_kb_reset = gtk_button_new_with_label("Reset Settings"); g_signal_connect(but_kb_reset,"clicked",G_CALLBACK(keybinds_conf_default), NULL); gtk_container_add(GTK_CONTAINER(hbox_kb_s), but_kb_reset); but_kb_close = gtk_button_new_with_label(" Close "); g_signal_connect(but_kb_close,"clicked",G_CALLBACK(keybinds_window_destroy), NULL); gtk_box_pack_end(GTK_BOX(hbox_kb_s),GTK_WIDGET(but_kb_close),FALSE,FALSE,0); but_kb_save = gtk_button_new_with_label("Save & Close"); g_signal_connect(but_kb_save,"clicked",G_CALLBACK(keybinds_conf_save), NULL); gtk_box_pack_end(GTK_BOX(hbox_kb_s),GTK_WIDGET(but_kb_save),FALSE,FALSE,0); gtk_widget_show_all(win_kb_main); }
static void on_activate (GApplication *app, gpointer data) { static GtkWidget *window = NULL; if (window == NULL) { GtkWidget *header, *sidebar_toggle, *animation_switch; GtkWidget *hbox, *revealer, *sidebar, *img; window = gtk_application_window_new (GTK_APPLICATION (app)); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); /* titlebar */ header = gtk_header_bar_new (); gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE); gtk_window_set_titlebar (GTK_WINDOW (window), header); sidebar_toggle = gtk_toggle_button_new_with_label ("Show Sidebar"); gtk_header_bar_pack_start (GTK_HEADER_BAR (header), sidebar_toggle); animation_switch = gtk_switch_new (); gtk_widget_set_valign (animation_switch, GTK_ALIGN_CENTER); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), animation_switch); gtk_header_bar_pack_end (GTK_HEADER_BAR (header), gtk_label_new ("Animations")); /* content */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_add (GTK_CONTAINER (window), hbox); revealer = gtk_revealer_new (); gtk_revealer_set_transition_type (GTK_REVEALER (revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); gtk_container_add (GTK_CONTAINER (hbox), revealer); sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_size_request (sidebar, 150, -1); gtk_style_context_add_class (gtk_widget_get_style_context (sidebar), GTK_STYLE_CLASS_SIDEBAR); gtk_container_add (GTK_CONTAINER (revealer), sidebar); img = gtk_image_new (); g_object_set (img, "icon-name", "face-smile-symbolic", "pixel-size", 128, "hexpand", TRUE, "halign", GTK_ALIGN_CENTER, "valign", GTK_ALIGN_CENTER, NULL); gtk_container_add (GTK_CONTAINER (hbox), img); g_object_bind_property (sidebar_toggle, "active", revealer, "reveal-child", G_BINDING_SYNC_CREATE); g_object_bind_property (gtk_settings_get_default(), "gtk-enable-animations", animation_switch, "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); } gtk_window_present (GTK_WINDOW (window)); }
static void add_location_app (CcPrivacyPanel *self, const gchar *app_id, gboolean enabled, gint64 last_used) { CcPrivacyPanelPrivate *priv = self->priv; GDesktopAppInfo *app_info; char *desktop_id; GtkWidget *box, *row, *w; GIcon *icon; GDateTime *t; char *last_used_str; LocationAppStateData *data; w = g_hash_table_lookup (priv->location_app_switches, app_id); if (w != NULL) { gtk_switch_set_active (GTK_SWITCH (w), enabled); return; } desktop_id = g_strdup_printf ("%s.desktop", app_id); app_info = g_desktop_app_info_new (desktop_id); g_free (desktop_id); if (app_info == NULL) return; row = gtk_list_box_row_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_margin_start (box, 12); gtk_widget_set_margin_end (box, 6); gtk_widget_set_margin_top (box, 12); gtk_widget_set_margin_bottom (box, 12); gtk_container_add (GTK_CONTAINER (row), box); gtk_widget_set_hexpand (box, TRUE); gtk_container_add (GTK_CONTAINER (priv->location_apps_list_box), row); icon = g_app_info_get_icon (G_APP_INFO (app_info)); w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_set_halign (w, GTK_ALIGN_CENTER); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_size_group_add_widget (priv->location_icon_size_group, w); gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); w = gtk_label_new (g_app_info_get_name (G_APP_INFO (app_info))); gtk_widget_set_margin_start (w, 12); gtk_widget_set_margin_end (w, 12); gtk_widget_set_halign (w, GTK_ALIGN_START); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_label_set_xalign (GTK_LABEL (w), 0); gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); t = g_date_time_new_from_unix_utc (last_used); last_used_str = cc_util_get_smart_date (t); w = gtk_label_new (last_used_str); g_free (last_used_str); gtk_style_context_add_class (gtk_widget_get_style_context (w), "dim-label"); gtk_widget_set_margin_start (w, 12); gtk_widget_set_margin_end (w, 12); gtk_widget_set_halign (w, GTK_ALIGN_END); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0); w = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (w), enabled); gtk_widget_set_halign (w, GTK_ALIGN_END); gtk_widget_set_valign (w, GTK_ALIGN_CENTER); gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0); g_settings_bind (priv->location_settings, LOCATION_ENABLED, w, "sensitive", G_SETTINGS_BIND_DEFAULT); g_hash_table_insert (priv->location_app_switches, g_strdup (app_id), g_object_ref (w)); data = g_slice_new (LocationAppStateData); data->self = self; data->app_id = g_strdup (app_id); data->widget = w; data->changing_state = FALSE; g_signal_connect_data (G_OBJECT (w), "state-set", G_CALLBACK (on_location_app_state_set), data, (GClosureNotify) location_app_state_data_free, 0); gtk_widget_show_all (row); }
/* channels_init */ static MixerControlPlugin * _channels_init(MixerControlPluginHelper * helper, String const * type, va_list properties) { MixerControlPlugin * channels; GtkWidget * hbox; GtkWidget * widget; #if !GTK_CHECK_VERSION(3, 14, 0) GtkWidget * align; #endif (void) type; if((channels = object_new(sizeof(*channels))) == NULL) return NULL; channels->helper = helper; channels->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_container_set_border_width(GTK_CONTAINER(channels->widget), 4); channels->delta = 1; channels->channels = NULL; channels->channels_cnt = 0; channels->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); #if GTK_CHECK_VERSION(3, 14, 0) gtk_widget_set_halign(channels->hbox, GTK_ALIGN_CENTER); gtk_box_pack_start(GTK_BOX(channels->widget), channels->hbox, TRUE, TRUE, 0); #else align = gtk_alignment_new(0.5, 0.5, 0.0, 1.0); gtk_container_add(GTK_CONTAINER(align), channels->hbox); gtk_box_pack_start(GTK_BOX(channels->widget), align, TRUE, TRUE, 0); #endif channels->bbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(channels->bbox), TRUE); /* bind */ channels->bind = gtk_toggle_button_new(); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); channels->bind_image = gtk_image_new_from_icon_name("gtk-connect", GTK_ICON_SIZE_BUTTON); gtk_box_pack_start(GTK_BOX(hbox), channels->bind_image, FALSE, TRUE, 0); widget = gtk_label_new(_("Bind")); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); gtk_widget_show_all(hbox); gtk_container_add(GTK_CONTAINER(channels->bind), hbox); gtk_widget_set_no_show_all(channels->bind, TRUE); g_signal_connect_swapped(channels->bind, "toggled", G_CALLBACK( _channels_on_bind_toggled), channels); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(hbox), channels->bind, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(channels->bbox), hbox, FALSE, TRUE, 0); /* mute */ #if GTK_CHECK_VERSION(3, 0, 0) channels->mute = gtk_switch_new(); g_signal_connect_swapped(channels->mute, "notify::active", G_CALLBACK(_channels_on_mute_notify_active), channels); #else channels->mute = gtk_toggle_button_new(); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); channels->mute_image = gtk_image_new_from_icon_name( "audio-volume-muted", GTK_ICON_SIZE_BUTTON); gtk_box_pack_start(GTK_BOX(hbox), channels->mute_image, FALSE, TRUE, 0); widget = gtk_label_new(_("Mute")); gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); gtk_widget_show_all(hbox); gtk_container_add(GTK_CONTAINER(channels->mute), hbox); g_signal_connect_swapped(channels->mute, "toggled", G_CALLBACK( _channels_on_mute_toggled), channels); #endif gtk_widget_set_no_show_all(channels->mute, TRUE); hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(hbox), channels->mute, TRUE, TRUE, 0); gtk_box_pack_end(GTK_BOX(channels->bbox), hbox, FALSE, TRUE, 0); gtk_box_pack_end(GTK_BOX(channels->widget), channels->bbox, FALSE, TRUE, 0); channels->signal = FALSE; if(_channels_set(channels, properties) != 0) { _channels_destroy(channels); return NULL; } return channels; }
gint main (gint argc, gchar **argv) { GtkWidget *window, *main_box, *container, *child; GtkWidget *box, *toolbar; GtkStyleProvider *provider; GtkTextBuffer *css; gtk_init (&argc, &argv); css = gtk_text_buffer_new (NULL); gtk_text_buffer_create_tag (css, "warning", "background", "rgba(255,255,0,0.3)", NULL); gtk_text_buffer_create_tag (css, "error", "background", "rgba(255,0,0,0.3)", NULL); provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), provider, GTK_STYLE_PROVIDER_PRIORITY_FORCE); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL); main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), main_box); toolbar = gtk_toolbar_new (); gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT); gtk_box_pack_start (GTK_BOX (main_box), toolbar, FALSE, TRUE, 0); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (main_box), box, FALSE, TRUE, 0); container = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW (container), 200); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (container), 200); gtk_box_pack_start (GTK_BOX (main_box), container, TRUE, TRUE, 0); child = gtk_text_view_new_with_buffer (css); gtk_container_add (GTK_CONTAINER (container), child); g_signal_connect (css, "changed", G_CALLBACK (css_text_changed), provider); gtk_text_buffer_set_text (css, DEFAULT_CSS, -1); g_signal_connect (provider, "parsing-error", G_CALLBACK (show_parsing_error), gtk_text_view_get_buffer (GTK_TEXT_VIEW (child))); container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (main_box), container, FALSE, TRUE, 0); child = gtk_switch_new (); gtk_switch_set_active (GTK_SWITCH (child), gtk_widget_get_default_direction () == GTK_TEXT_DIR_LTR); g_signal_connect (child, "notify::active", G_CALLBACK (set_orientation), NULL); gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0); child = gtk_label_new ("left-to-right"); gtk_box_pack_start (GTK_BOX (container), child, FALSE, FALSE, 0); child = gtk_button_new_with_label ("Add button"); g_signal_connect_swapped (child, "clicked", G_CALLBACK (add_button), box); gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0); child = gtk_button_new_with_label ("Add toolbutton"); g_signal_connect_swapped (child, "clicked", G_CALLBACK (add_toolbutton), toolbar); gtk_box_pack_end (GTK_BOX (container), child, FALSE, FALSE, 0); add_toolbutton (GTK_TOOLBAR (toolbar)); add_toolbutton (GTK_TOOLBAR (toolbar)); add_toolbutton (GTK_TOOLBAR (toolbar)); add_toolbutton (GTK_TOOLBAR (toolbar)); add_button (GTK_BOX (box)); add_button (GTK_BOX (box)); add_button (GTK_BOX (box)); add_button (GTK_BOX (box)); gtk_widget_show_all (window); gtk_main (); return 0; }
static void pocketvox_setup_add_module(PocketvoxSetup *setup, gchar* key, gchar* value, gboolean isapps) { g_return_if_fail(NULL != setup); setup->priv = G_TYPE_INSTANCE_GET_PRIVATE (setup, TYPE_POCKETVOX_SETUP, PocketvoxSetupPrivate); PocketvoxSetupPrivate *priv = setup->priv; ModuleInfos *info = (ModuleInfos *)g_malloc0(sizeof(ModuleInfos)); GtkWidget* row = gtk_list_box_row_new(); gchar *name = g_strdup_printf("row_%d",current_line); gtk_widget_set_name(row, name); GtkWidget* grid = gtk_grid_new(); info->entry_id = gtk_entry_new(); if(key != NULL) { gtk_entry_set_text(GTK_ENTRY(info->entry_id), key); } gtk_entry_set_placeholder_text(GTK_ENTRY(info->entry_id), _("your-id")); gtk_widget_set_tooltip_text(info->entry_id, _("Set the module's id")); info->sw = gtk_switch_new(); gtk_widget_set_tooltip_text(info->sw, _("is this module associated to an desktop application ?")); info->entry_path = gtk_entry_new(); gtk_entry_set_icon_from_icon_name (GTK_ENTRY(info->entry_path), GTK_ENTRY_ICON_SECONDARY, "gtk-search"); gtk_entry_set_placeholder_text(GTK_ENTRY(info->entry_path), _("your path")); gtk_widget_set_tooltip_text(info->entry_path,_("Set the dictionnary's path")); g_signal_connect(info->entry_path, "icon-press", G_CALLBACK(pocketvox_setup_search_dict), NULL); //gtk_widget_set_hexpand(label_app, TRUE); gtk_widget_set_hexpand(info->entry_path, TRUE); gtk_widget_set_hexpand(info->entry_id, TRUE); gtk_widget_set_hexpand(info->sw, FALSE); g_object_set(G_OBJECT(info->sw), "active", isapps, NULL); if(value != NULL) { gtk_entry_set_text(GTK_ENTRY(info->entry_path), value); } gtk_grid_set_row_homogeneous(GTK_GRID(grid), FALSE); gtk_grid_attach(GTK_GRID(grid), info->entry_id, 0, 0, 2, 1); gtk_grid_attach(GTK_GRID(grid), info->entry_path, 2, 0, 2, 1); gtk_grid_attach(GTK_GRID(grid), info->sw, 4, 0, 1, 1); gtk_container_add(GTK_CONTAINER(row), grid); gtk_widget_show_all(row); gtk_list_box_prepend(GTK_LIST_BOX(priv->listBox), row); g_hash_table_insert(priv->apps, g_strdup(name), info); current_line ++; }
static void deja_dup_config_photo_dialog_create_widgets (DejaDupConfigPhotoDialog* self) { const gchar* _tmp0_ = NULL; GtkLabel* _tmp1_; GtkLabel* _tmp2_; GtkLabel* label; GtkSwitch* _tmp3_; GtkSwitch* _tmp4_; const gchar* _tmp5_ = NULL; GtkLabel* _tmp6_; GtkLabel* _tmp7_; GtkLabel* description; GtkBox* _tmp8_; GtkBox* _tmp9_; GtkBox* hbox; GtkSwitch* _tmp10_; GtkBox* _tmp11_ = NULL; GtkBox* _tmp12_; GtkBox* content; DejaDupSimpleSettings* _tmp13_ = NULL; DejaDupSimpleSettings* settings; gboolean _tmp14_ = FALSE; gboolean value; GtkSwitch* _tmp15_; GtkSwitch* _tmp16_; g_return_if_fail (self != NULL); _tmp0_ = _ ("Photo Stream"); _tmp1_ = (GtkLabel*) gtk_label_new_with_mnemonic (_tmp0_); _tmp2_ = g_object_ref_sink (_tmp1_); label = _tmp2_; _tmp3_ = (GtkSwitch*) gtk_switch_new (); _tmp4_ = g_object_ref_sink (_tmp3_); _g_object_unref0 (self->priv->button); self->priv->button = _tmp4_; _tmp5_ = _ ("Automatically upload photos and send them to all of you devices."); _tmp6_ = (GtkLabel*) gtk_label_new_with_mnemonic (_tmp5_); _tmp7_ = g_object_ref_sink (_tmp6_); description = _tmp7_; g_object_set ((GObject*) description, "use-markup", TRUE, "xalign", 0.5f, NULL); _tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20); _tmp9_ = g_object_ref_sink (_tmp8_); hbox = _tmp9_; gtk_box_pack_start (hbox, (GtkWidget*) label, FALSE, TRUE, (guint) 0); _tmp10_ = self->priv->button; gtk_box_pack_end (hbox, (GtkWidget*) _tmp10_, FALSE, FALSE, (guint) 0); _tmp11_ = gtk_dialog_get_content_area ((GtkDialog*) self); _tmp12_ = _g_object_ref0 (GTK_IS_BOX (_tmp11_) ? ((GtkBox*) _tmp11_) : NULL); content = _tmp12_; gtk_box_pack_start (content, (GtkWidget*) hbox, FALSE, TRUE, (guint) 0); gtk_box_set_spacing (content, 10); _tmp13_ = deja_dup_get_settings (DEJA_DUP_APPS_ROOT ".photo-stream"); settings = _tmp13_; _tmp14_ = g_settings_get_boolean ((GSettings*) settings, DEJA_DUP_BACKUP_KEY); value = _tmp14_; _tmp15_ = self->priv->button; gtk_switch_set_active (_tmp15_, value); _tmp16_ = self->priv->button; g_signal_connect_object ((GObject*) _tmp16_, "notify::active", (GCallback) _deja_dup_config_photo_dialog_handle_toggled_g_object_notify, self, 0); gtk_dialog_add_button ((GtkDialog*) self, GTK_STOCK_CLOSE, (gint) GTK_RESPONSE_CLOSE); _g_object_unref0 (settings); _g_object_unref0 (content); _g_object_unref0 (hbox); _g_object_unref0 (description); _g_object_unref0 (label); }
int music_build_element_widgets () { int i = 0; for (i = 0; i < 9; i++) { label_music_info[i] = gtk_label_new(NULL); gtk_label_set_width_chars(GTK_LABEL(label_music_info[i]), 15); gtk_label_set_max_width_chars(GTK_LABEL(label_music_info[i]), 150); gtk_label_set_line_wrap(GTK_LABEL(label_music_info[i]), TRUE); } separator_music_info = gtk_separator_new(GTK_ORIENTATION_VERTICAL); for (i = 0; i < 9; i++) { label_music_lyric[i] = gtk_label_new(NULL); gtk_label_set_max_width_chars(GTK_LABEL(label_music_lyric[i]), 305); // gtk_label_set_line_wrap(GTK_LABEL(label_music_lyric[i]), TRUE); } gtk_label_set_selectable(GTK_LABEL(label_music_lyric[4]), TRUE); gtk_label_set_use_underline (GTK_LABEL(label_music_lyric[4]), TRUE); gtk_label_set_use_markup (GTK_LABEL(label_music_lyric[4]), TRUE); gtk_label_set_pattern (GTK_LABEL(label_music_lyric[4]), "________"); separator_music_lyric1 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); separator_music_lyric2 = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); button_music_start_server = gtk_button_new_with_label("启动服务器"); // set_button_music_start_server(button_music_start_server); button_music_exit_server = gtk_button_new_with_label("关闭服务器"); // set_button_music_exit_server(button_music_exit_server); button_music_play = gtk_button_new(); // box_music_play = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png"); // box_music_pause = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png"); image_music_play = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png"); image_music_play_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play_light.png"); image_music_pause = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png"); image_music_pause_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause_light.png"); gtk_button_set_relief(GTK_BUTTON(button_music_play), GTK_RELIEF_NONE); set_button_music_play(button_music_play); button_music_pause = gtk_button_new_with_label("暂停"); // set_button_music_pause(button_music_pause); button_music_unpause = gtk_button_new_with_label("取消暂停"); // set_button_music_unpause(button_music_unpause); // button_music_stop = gtk_button_new_with_label("停止"); button_music_stop = gtk_button_new(); image_music_stop = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop.png"); image_music_stop_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop_light.png"); gtk_button_set_image(GTK_BUTTON(button_music_stop), image_music_stop); gtk_button_set_relief(GTK_BUTTON(button_music_stop), GTK_RELIEF_NONE); set_button_music_stop(button_music_stop); // button_music_next = gtk_button_new_with_label("下一首"); button_music_next = gtk_button_new(); image_music_next = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next.png"); image_music_next_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next_light.png"); gtk_button_set_image(GTK_BUTTON(button_music_next), image_music_next); gtk_button_set_relief(GTK_BUTTON(button_music_next), GTK_RELIEF_NONE); set_button_music_next(button_music_next); // button_music_pre = gtk_button_new_with_label("上一首"); button_music_pre = gtk_button_new(); image_music_pre = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre.png"); image_music_pre_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre_light.png"); gtk_button_set_image (GTK_BUTTON(button_music_pre), image_music_pre); gtk_button_set_relief(GTK_BUTTON(button_music_pre), GTK_RELIEF_NONE); set_button_music_pre(button_music_pre); // button_music_volume_up = gtk_button_new_with_label("音量+"); // set_button_music_volume_up(button_music_volume_up); // button_music_volume_silence = gtk_button_new_with_label("静音"); button_music_silence = gtk_button_new(); image_music_silence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence.png"); image_music_silence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence_light.png"); image_music_unsilence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence.png"); image_music_unsilence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence_light.png"); gtk_button_set_image (GTK_BUTTON(button_music_silence), image_music_silence); gtk_button_set_relief(GTK_BUTTON(button_music_silence), GTK_RELIEF_NONE); set_button_music_silence(button_music_silence); button_music_volume = gtk_volume_button_new(); set_button_music_volume( button_music_volume); button_music_reset_list = gtk_button_new_with_label("重设列表"); set_button_music_reset_list(button_music_reset_list); // button_music_choose_path = gtk_button_new_with_label("添加路径"); // set_button_music_choose_path(button_music_choose_path); // music_path_dialog = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); music_path_dialog = gtk_file_chooser_dialog_new ("test_title", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "test_button_text", NULL); button_music_choose_path = gtk_file_chooser_button_new_with_dialog (music_path_dialog); gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON(button_music_choose_path), "添加路径"); // gtk_file_chooser_set_select_multiple (music_path_dialog, TRUE); button_music_delete_path = gtk_button_new_with_label("删除当前路径"); set_button_music_delete_path(button_music_delete_path); scale_music_process = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); set_scale_music_process(scale_music_process); label_music_cur_time = gtk_label_new ("--:--:--"); label_music_total_time = gtk_label_new ("--:--:--"); switch_music_autonext = gtk_switch_new (); set_switch_music_autonext (); label_music_autonext = gtk_label_new ("AutoNext: "); switch_music_repeat = gtk_switch_new (); set_switch_music_repeat (); label_music_repeat = gtk_label_new ("Repeat: "); switch_music_shuffle = gtk_switch_new (); set_switch_music_shuffle (); label_music_shuffle = gtk_label_new ("Shuffle: "); radio_button_music_mode_shuffle = gtk_radio_button_new (NULL); label_music_mode_shuffle = gtk_label_new ("随机:"); radio_button_music_mode_loop_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle)); label_music_mode_loop_list = gtk_label_new ("列表循环:"); radio_button_music_mode_play_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle)); label_music_mode_play_list = gtk_label_new ("播放列表:"); radio_button_music_mode_loop_one = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle)); label_music_mode_loop_one = gtk_label_new ("单曲:"); spinner_music_mode_changing = gtk_spinner_new (); set_radio_button_music_mode (); store_music_dir_list = gtk_tree_store_new(dir_n_columns, G_TYPE_STRING); tree_view_music_dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_dir_list)); text_renderer_music_dir_list = gtk_cell_renderer_text_new (); column_music_dir_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_dir_list, "text", dir_name, NULL); gtk_tree_view_column_set_fixed_width(column_music_dir_list, 100); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_dir_list), column_music_dir_list); music_dir_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50); music_dir_list_sw = gtk_scrolled_window_new(NULL, music_dir_list_sw_adj_h); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_dir_list_sw), 330); gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_dir_list_sw), 100); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_SHADOW_NONE); // gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(music_dir_list_sw), tree_view_music_dir_list); selection_music_dir_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_dir_list)); set_tree_view_music_dir_list (); store_music_list = gtk_tree_store_new(list_n_columns, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // char file_index[BUFSIZ]; // printf("music_list_num is: %s\n", music_list_num); // while (i < music_list_num) { // // printf("%d: %s\n", i, music_list[i]); // sprintf(file_index, "%d", i + 1); // gtk_tree_store_append(store_music_list, &iter_music_list, NULL); // gtk_tree_store_set (store_music_list, &iter_music_list, list_index, file_index, list_title, music_list[i], list_total_sec, "03:00", -1); // i++; // } // tree_view_music_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_list)); text_renderer_music_list = gtk_cell_renderer_text_new (); column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_index, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list); gtk_tree_view_column_set_title(column_music_list, "序号"); text_renderer_music_list = gtk_cell_renderer_text_new (); column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_title, NULL); gtk_tree_view_column_set_fixed_width(column_music_list, 100); gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list); // text_renderer_music_list = gtk_cell_renderer_text_new (); // column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_total_sec, NULL); // gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list); music_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50); music_list_sw = gtk_scrolled_window_new(NULL, music_list_sw_adj_h); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_list_sw), 370); gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_list_sw), 200); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_list_sw), GTK_SHADOW_NONE); // gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(music_list_sw), tree_view_music_list); selection_music_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_list)); set_tree_view_music_list (); return 1; }