diff options
Diffstat (limited to 'src/widgets/spw-utilities.cpp')
| -rw-r--r-- | src/widgets/spw-utilities.cpp | 125 |
1 files changed, 6 insertions, 119 deletions
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 68fb78327..992f1f6b7 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -61,31 +61,6 @@ Gtk::Label * spw_label(Gtk::Grid *table, const gchar *label_text, int col, int r return label_widget; } -GtkWidget * -spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) -{ - GtkWidget *label_widget; - - label_widget = gtk_label_new (label_text); - g_assert(label_widget != NULL); - gtk_widget_set_halign(label_widget, GTK_ALIGN_END); - gtk_widget_show (label_widget); - -#if GTK_CHECK_VERSION(3,12,0) - gtk_widget_set_margin_start(label_widget, 4); - gtk_widget_set_margin_end(label_widget, 4); -#else - gtk_widget_set_margin_left(label_widget, 4); - gtk_widget_set_margin_right(label_widget, 4); -#endif - gtk_widget_set_hexpand(label_widget, TRUE); - gtk_widget_set_halign(label_widget, GTK_ALIGN_FILL); - gtk_widget_set_valign(label_widget, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(table), label_widget, col, row, 1, 1); - - return label_widget; -} - /** * Creates a horizontal layout manager with 4-pixel spacing between children * and space for 'width' columns. @@ -104,94 +79,6 @@ Gtk::HBox * spw_hbox(Gtk::Grid * table, int width, int col, int row) return hb; } -/** - * Creates a checkbutton widget and adds it to a vbox. - * This is a compound widget that includes a label. - */ -GtkWidget *spw_vbox_checkbutton(GtkWidget *dialog, GtkWidget *vbox, - const gchar *label, const gchar *tip, gchar *key, GCallback cb) -{ - g_assert (dialog != NULL); - g_assert (vbox != NULL); - - GtkWidget *b = gtk_check_button_new_with_label (label); - gtk_widget_set_tooltip_text(b, tip); - g_assert (b != NULL); - gtk_widget_show (b); - gtk_box_pack_start (GTK_BOX (vbox), b, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT (b), "key", key); - g_object_set_data (G_OBJECT (dialog), key, b); - g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); - return b; -} - - -/** - * Creates a checkbutton widget and adds it to a table. - * This is a compound widget that includes a label. - */ -GtkWidget * -spw_checkbutton(GtkWidget * dialog, GtkWidget * table, - const gchar * label, gchar * key, int /*col*/, int row, - int insensitive, GCallback cb) -{ - GtkWidget *b; - - g_assert(dialog != NULL); - g_assert(table != NULL); - - GtkWidget *l = gtk_label_new (label); - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_widget_show (l); - - gtk_widget_set_halign(l, GTK_ALIGN_FILL); - gtk_widget_set_hexpand(l, TRUE); - gtk_widget_set_valign(l, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(table), l, 0, row, 1, 1); - - b = gtk_check_button_new (); - gtk_widget_show (b); - - gtk_widget_set_halign(b, GTK_ALIGN_FILL); - gtk_widget_set_hexpand(b, TRUE); - gtk_widget_set_valign(b, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(table), b, 1, row, 1, 1); - - g_object_set_data (G_OBJECT (b), "key", key); - g_object_set_data (G_OBJECT (dialog), key, b); - g_signal_connect (G_OBJECT (b), "toggled", cb, dialog); - if (insensitive == 1) { - gtk_widget_set_sensitive (b, FALSE); - } - return b; -} - -/** - * Creates a dropdown widget. This is a compound widget that includes - * a label as well as the dropdown. - */ -GtkWidget * -spw_dropdown(GtkWidget * dialog, GtkWidget * table, - const gchar * label_text, gchar * key, int row, - GtkWidget * selector - ) -{ - g_assert(dialog != NULL); - g_assert(table != NULL); - g_assert(selector != NULL); - - spw_label_old(table, label_text, 0, row); - - gtk_widget_show (selector); - gtk_widget_set_halign(selector, GTK_ALIGN_FILL); - gtk_widget_set_hexpand(selector, TRUE); - gtk_widget_set_valign(selector, GTK_ALIGN_CENTER); - gtk_grid_attach(GTK_GRID(table), selector, 1, row, 1, 1); - - g_object_set_data (G_OBJECT (dialog), key, selector); - return selector; -} - static void sp_set_font_size_recursive (GtkWidget *w, gpointer font) { @@ -249,9 +136,9 @@ gpointer sp_search_by_data_recursive(GtkWidget *w, gpointer key) if (r) return r; if (GTK_IS_CONTAINER(w)) { - GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); - for (GList *i = ch; i != NULL; i = i->next) { - r = sp_search_by_data_recursive(GTK_WIDGET(i->data), key); + std::vector<Gtk::Widget*> children = Glib::wrap(GTK_CONTAINER(w))->get_children(); + for (auto i:children) { + r = sp_search_by_data_recursive(GTK_WIDGET(i->gobj()), key); if (r) return r; } } @@ -272,9 +159,9 @@ GtkWidget *sp_search_by_value_recursive(GtkWidget *w, gchar *key, gchar *value) if (r && !strcmp (r, value)) return w; if (GTK_IS_CONTAINER(w)) { - GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); - for (GList *i = ch; i != NULL; i = i->next) { - GtkWidget *child = sp_search_by_value_recursive(GTK_WIDGET(i->data), key, value); + std::vector<Gtk::Widget*> children = Glib::wrap(GTK_CONTAINER(w))->get_children(); + for (auto i:children) { + GtkWidget *child = sp_search_by_value_recursive(GTK_WIDGET(i->gobj()), key, value); if (child) return child; } } |
