1 /* MManager - a Desktop wide manager for multimedia applications.
3 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include "mm-gtk-filter-builder.h"
25 G_DEFINE_TYPE (MMGtkFilterBuilder
, mm_gtk_filter_builder
, GTK_TYPE_V_BOX
);
27 #define MM_GTK_FILTER_BUILDER_GET_PRIVATE(o) \
28 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_GTK_TYPE_FILTER_BUILDER, MMGtkFilterBuilderPrivate))
30 struct MMGtkFilterBuilderDetails
{
31 GtkListStore
*filter_store
;
32 GtkTreeView
*fitler_view
;
35 GtkWidget
*attr_combo
;
36 GtkWidget
*logic_combo
;
37 GtkWidget
*value_entry
;
41 mm_gtk_filter_builder_class_init (MMGtkFilterBuilderClass
*klass
)
43 g_type_class_add_private (klass
, sizeof (MMGtkFilterBuilderDetails
));
47 mm_gtk_filter_builder_init (MMGtkFilterBuilder
*self
)
49 MMGtkFilterBuilderDetails
*details
= self
->details
=
50 MM_GTK_FILTER_BUILDER_GET_PRIVATE (self
);
51 GtkTreeView
*filter_view
;
52 GtkTreeColumn
*column
;
53 GtkCellRenderer
*renderer
;
57 details
->filter_store
= gtk_list_store_new (3,
58 G_TYPE_STRING
, /* attribute name */
59 G_TYPE_STRING
, /* operator */
60 G_TYPE_STRING
); /* value */
61 filter_view
= gtk_tree_view_new_with_model (GTK_TREE_MODEL (details
->filter_store
));
62 renderer
= gtk_cell_renderer_text_new ();
63 column
= gtk_tree_view_column_new_with_attributes (_("Parameter"),
67 gtk_tree_view_append_column (filter_view
, column
);
68 column
= gtk_tree_view_column_new_with_attributes (_("Logic"),
72 gtk_tree_view_append_column (filter_view
, column
);
73 column
= gtk_tree_view_column_new_with_attributes (_("Value"),
77 gtk_tree_view_append_column (filter_view
, column
);
78 details
->filter_view
= filter_view
;
79 gtk_box_pack_start (GTK_BOX (self
), GTK_WIDGET (filter_view
),
81 gtk_widget_show (filter_view
);
83 table
= gtk_table_new (3, 4, FALSE
);
84 w
= gtk_label_new_with_mnemonic (_("Attribute _category"));
85 gtk_table_attach_defaults (GTK_TABLE (table
), w
,
87 details
->cat_combo
= gtk_combo_box_new ();
88 gtk_table_attach_defaults (GTK_TABLE (table
), details
->cat_combo
,
90 w
= gtk_label_new_with_mnemonic (_("Attribute _name"));
91 gtk_table_attach_defaults (GTK_TABLE (table
), w
,
93 details
->attr_combo
= gtk_combo_new ();
94 gtk_table_attach_defaults (GTK_TABLE (table
), details
->attr_combo
,
96 w
= gtk_label_new_with_mnemonic (_("_Logic"));
97 gtk_table_attach_defaults (GTK_TABLE (table
), w
,
99 details
->logic_combo
= gtk_combo_new ();
100 gtk_table_attach_defaults (GTK_TABLE (table
), details
->logic_combo
,
102 w
= gtk_label_new_with_mnemonic (_("_Value"));
103 gtk_table_attach_defaults (GTK_TABLE (table
), w
,
105 details
->value_entry
= gtk_entry_new ();
106 gtk_table_attach_defaults (GTK_TABLE (table
), details
->value_entry
,
108 w
= gtk_button_new_from_stock (GTK_STOCK_ADD
);
109 gtk_table_attach_defaults (GTK_TABLE (table
), w
,
111 gtk_widget_show_all (table
);
115 mm_gtk_filter_builder_new (MMCategory
*category
)
117 MMGtkFilterBuilder
*self
;
119 self
= MM_GTK_FILTER_BUILDER (g_object_new (MM_GTK_TYPE_FILTER_BUILDER
, NULL
));
120 populate_from_category (self
, category
);