mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Port testtreeview to new API
Use GtkComboBox instead the deprecated GtkOptionMenu https://bugzilla.gnome.org/show_bug.cgi?id=616679
This commit is contained in:
parent
623966b6da
commit
2c2726f818
@ -18,7 +18,6 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
#include <string.h>
|
||||
#include "prop-editor.h"
|
||||
#include <gtk/gtk.h>
|
||||
@ -658,12 +657,12 @@ create_tree_model (void)
|
||||
}
|
||||
|
||||
static void
|
||||
model_selected (GtkOptionMenu *om, gpointer data)
|
||||
model_selected (GtkComboBox *combo_box, gpointer data)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (data);
|
||||
gint hist;
|
||||
|
||||
hist = gtk_option_menu_get_history (om);
|
||||
hist = gtk_combo_box_get_active (combo_box);
|
||||
|
||||
if (models[hist] != gtk_tree_view_get_model (tree_view))
|
||||
{
|
||||
@ -672,12 +671,12 @@ model_selected (GtkOptionMenu *om, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
columns_selected (GtkOptionMenu *om, gpointer data)
|
||||
columns_selected (GtkComboBox *combo_box, gpointer data)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (data);
|
||||
gint hist;
|
||||
|
||||
hist = gtk_option_menu_get_history (om);
|
||||
hist = gtk_combo_box_get_active (combo_box);
|
||||
|
||||
if (hist != get_columns_type ())
|
||||
{
|
||||
@ -704,8 +703,7 @@ main (int argc,
|
||||
GtkWidget *sw;
|
||||
GtkWidget *tv;
|
||||
GtkWidget *table;
|
||||
GtkWidget *om;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *combo_box;
|
||||
GtkTreeModel *model;
|
||||
gint i;
|
||||
|
||||
@ -756,77 +754,34 @@ main (int argc,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
|
||||
/* Model menu */
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
combo_box = gtk_combo_box_new_text ();
|
||||
for (i = 0; i < MODEL_LAST; i++)
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), model_names[i]);
|
||||
|
||||
i = 0;
|
||||
while (i < MODEL_LAST)
|
||||
{
|
||||
GtkWidget *mi;
|
||||
const char *name;
|
||||
|
||||
name = model_names[i];
|
||||
|
||||
mi = gtk_menu_item_new_with_label (name);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
#if 0
|
||||
window = create_prop_editor (G_OBJECT (models[i]));
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window),
|
||||
name);
|
||||
#endif
|
||||
|
||||
++i;
|
||||
}
|
||||
gtk_widget_show_all (menu);
|
||||
|
||||
om = gtk_option_menu_new ();
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table), om,
|
||||
gtk_table_attach (GTK_TABLE (table), combo_box,
|
||||
0, 1, 0, 1,
|
||||
0, 0,
|
||||
0, 0);
|
||||
|
||||
g_signal_connect (om,
|
||||
g_signal_connect (combo_box,
|
||||
"changed",
|
||||
G_CALLBACK (model_selected),
|
||||
tv);
|
||||
|
||||
/* Columns menu */
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
combo_box = gtk_combo_box_new_text ();
|
||||
for (i = 0; i < COLUMNS_LAST; i++)
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), column_type_names[i]);
|
||||
|
||||
i = 0;
|
||||
while (i < COLUMNS_LAST)
|
||||
{
|
||||
GtkWidget *mi;
|
||||
const char *name;
|
||||
|
||||
name = column_type_names[i];
|
||||
|
||||
mi = gtk_menu_item_new_with_label (name);
|
||||
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
|
||||
|
||||
++i;
|
||||
}
|
||||
gtk_widget_show_all (menu);
|
||||
|
||||
om = gtk_option_menu_new ();
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table), om,
|
||||
gtk_table_attach (GTK_TABLE (table), combo_box,
|
||||
0, 1, 1, 2,
|
||||
0, 0,
|
||||
0, 0);
|
||||
|
||||
set_columns_type (GTK_TREE_VIEW (tv), COLUMNS_LOTS);
|
||||
gtk_option_menu_set_history (GTK_OPTION_MENU (om), COLUMNS_LOTS);
|
||||
|
||||
g_signal_connect (om,
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), COLUMNS_LOTS);
|
||||
|
||||
g_signal_connect (combo_box,
|
||||
"changed",
|
||||
G_CALLBACK (columns_selected),
|
||||
tv);
|
||||
|
Loading…
Reference in New Issue
Block a user