summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJody Goldberg <jody@gnome.org>2002-07-17 04:29:11 +0000
committerJody Goldberg <jody@src.gnome.org>2002-07-17 04:29:11 +0000
commit82c39eb541c416c9e8941a18ae7a0e5b626688b2 (patch)
treee2a03b6746596eb7ea1986cfd582188237498070
parent76214e33c0707a52b938faf967ee68e9d9ee3ac4 (diff)
downloadgnome-control-center-82c39eb541c416c9e8941a18ae7a0e5b626688b2.tar.gz
only enable the remove button when there is a selection.
2002-07-17 Jody Goldberg <jody@gnome.org> * mime-edit-dialog.c (mime_edit_dialog_init) : only enable the remove button when there is a selection.
-rw-r--r--capplets/file-types/ChangeLog5
-rw-r--r--capplets/file-types/file-types-properties.glade31
-rw-r--r--capplets/file-types/mime-edit-dialog.c39
3 files changed, 64 insertions, 11 deletions
diff --git a/capplets/file-types/ChangeLog b/capplets/file-types/ChangeLog
index 78c793664..e44d5e327 100644
--- a/capplets/file-types/ChangeLog
+++ b/capplets/file-types/ChangeLog
@@ -1,3 +1,8 @@
+2002-07-17 Jody Goldberg <jody@gnome.org>
+
+ * mime-edit-dialog.c (mime_edit_dialog_init) : only enable the remove
+ button when there is a selection.
+
2002-07-16 Jody Goldberg <jody@gnome.org>
* file-types-properties.glade (</) : rearrange the extensions area.
diff --git a/capplets/file-types/file-types-properties.glade b/capplets/file-types/file-types-properties.glade
index 26d940e5b..39e079a36 100644
--- a/capplets/file-types/file-types-properties.glade
+++ b/capplets/file-types/file-types-properties.glade
@@ -456,10 +456,31 @@
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
- <property name="n_columns">2</property>
+ <property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
- <property name="column_spacing">0</property>
+ <property name="column_spacing">4</property>
+
+ <child>
+ <widget class="GtkLabel" id="add_ext_label">
+ <property name="label" translatable="yes">Add:</property>
+ <property name="justify">GTK_JUSTIFY_CENTER</property>
+ <property name="wrap">no</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">4</property>
+ <property name="ypad">0</property>
+ <property name="visible">yes</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
<child>
<widget class="GtkEntry" id="new_ext_entry">
@@ -486,7 +507,7 @@
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="xalign">1</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">1</property>
@@ -544,8 +565,8 @@
</child>
</widget>
<packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">2</property>
</packing>
diff --git a/capplets/file-types/mime-edit-dialog.c b/capplets/file-types/mime-edit-dialog.c
index b2e2bbcf2..1f48b7b63 100644
--- a/capplets/file-types/mime-edit-dialog.c
+++ b/capplets/file-types/mime-edit-dialog.c
@@ -160,11 +160,28 @@ mime_edit_editable_enters (MimeEditDialog *dialog, GtkEditable *editable)
}
static void
+check_for_content (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
+ gpointer data)
+{
+ *((gboolean *)data) = TRUE;
+}
+
+static void
+remove_ext_sensitivity_cb (GtkTreeSelection *selection, GtkWidget *button)
+{
+ gboolean flag = FALSE;
+ gtk_tree_selection_selected_foreach (selection, check_for_content, &flag);
+ gtk_widget_set_sensitive (GTK_WIDGET (button), flag);
+}
+
+static void
mime_edit_dialog_init (MimeEditDialog *dialog, MimeEditDialogClass *class)
{
GtkSizeGroup *size_group;
GtkTreeView *view;
GtkCellRenderer *renderer;
+ GtkWidget *remove_ext;
+ GtkTreeSelection *selection;
dialog->p = g_new0 (MimeEditDialogPrivate, 1);
dialog->p->dialog_xml = glade_xml_new
@@ -199,12 +216,22 @@ mime_edit_dialog_init (MimeEditDialog *dialog, MimeEditDialogClass *class)
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->p->dialog_win)->vbox), WID ("edit_widget"), TRUE, TRUE, 0);
- g_signal_connect_swapped (G_OBJECT (WID ("new_ext_entry")), "activate", (GCallback) add_ext_cb, dialog);
- g_signal_connect_swapped (G_OBJECT (WID ("remove_ext_button")), "clicked", (GCallback) remove_ext_cb, dialog);
- g_signal_connect_swapped (G_OBJECT (WID ("choose_button")), "clicked", (GCallback) choose_cat_cb, dialog);
- g_signal_connect_swapped (G_OBJECT (WID ("default_action_select")), "changed", (GCallback) default_action_changed_cb, dialog);
-
- g_signal_connect_swapped (G_OBJECT (dialog->p->dialog_win), "response", (GCallback) response_cb, dialog);
+ remove_ext = WID ("remove_ext_button");
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (WID ("ext_list")));
+ g_signal_connect (G_OBJECT (selection), "changed",
+ (GCallback) remove_ext_sensitivity_cb, remove_ext);
+ g_signal_connect_swapped (G_OBJECT (remove_ext), "clicked",
+ (GCallback) remove_ext_cb, dialog);
+ g_signal_connect_swapped (G_OBJECT (WID ("new_ext_entry")), "activate",
+ (GCallback) add_ext_cb, dialog);
+ g_signal_connect_swapped (G_OBJECT (WID ("choose_button")), "clicked",
+ (GCallback) choose_cat_cb, dialog);
+ g_signal_connect_swapped (G_OBJECT (WID ("default_action_select")), "changed",
+ (GCallback) default_action_changed_cb, dialog);
+ g_signal_connect_swapped (G_OBJECT (dialog->p->dialog_win), "response",
+ (GCallback) response_cb, dialog);
+
+ remove_ext_sensitivity_cb (selection, (gpointer)remove_ext);
mime_edit_editable_enters (dialog, GTK_EDITABLE (WID ("description_entry")));
mime_edit_editable_enters (dialog, GTK_EDITABLE (WID ("mime_type_entry")));