[18371] | 1 | /* |
---|
| 2 | * This program is free software; you can redistribute it and/or modify |
---|
| 3 | * it under the terms of the GNU General Public License as published by |
---|
| 4 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 5 | * (at your option) any later version. |
---|
| 6 | * |
---|
| 7 | * This program is distributed in the hope that it will be useful, |
---|
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 10 | * GNU General Public License for more details. |
---|
| 11 | * |
---|
| 12 | * You should have received a copy of the GNU General Public License |
---|
| 13 | * along with this program; if not, write to the Free Software |
---|
| 14 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #ifdef HAVE_CONFIG_H |
---|
| 18 | #include <config.h> |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | #include <panel-applet.h> |
---|
| 22 | #include <panel-applet-gconf.h> |
---|
| 23 | #include <gconf/gconf.h> |
---|
| 24 | #include <gconf/gconf-client.h> |
---|
| 25 | |
---|
| 26 | #include "drivemount.h" |
---|
| 27 | #include "properties.h" |
---|
| 28 | |
---|
| 29 | typedef struct _ResponseWidgets |
---|
| 30 | { |
---|
| 31 | DriveData *dd; |
---|
| 32 | GtkWidget *mount_entry; |
---|
| 33 | GtkWidget *update_spin; |
---|
| 34 | GtkWidget *omenu; |
---|
| 35 | GtkWidget *icon_entry_in; |
---|
| 36 | GtkWidget *icon_entry_out; |
---|
| 37 | GtkWidget *scale_toggle; |
---|
| 38 | GtkWidget *eject_toggle; |
---|
| 39 | GtkWidget *automount_toggle; |
---|
| 40 | }ResponseWidgets; |
---|
| 41 | |
---|
| 42 | static void handle_response_cb(GtkDialog *dialog, gint response, ResponseWidgets *widgets); |
---|
| 43 | static void set_widget_sensitivity_false_cb(GtkWidget *widget, GtkWidget *target); |
---|
| 44 | static void set_widget_sensitivity_true_cb(GtkWidget *widget, GtkWidget *target); |
---|
| 45 | static gchar *remove_level_from_path(const gchar *path); |
---|
| 46 | static void sync_mount_base(DriveData *dd); |
---|
| 47 | |
---|
| 48 | void |
---|
| 49 | properties_load(DriveData *dd) |
---|
| 50 | { |
---|
| 51 | GConfClient *client; |
---|
| 52 | gchar *key; |
---|
| 53 | GError *error = NULL; |
---|
| 54 | |
---|
| 55 | client = gconf_client_get_default (); |
---|
| 56 | key = panel_applet_get_preferences_key (PANEL_APPLET (dd->applet)); |
---|
| 57 | |
---|
| 58 | if (gconf_client_dir_exists (client, key, NULL)) { |
---|
| 59 | dd->interval = panel_applet_gconf_get_int(PANEL_APPLET(dd->applet), "interval", &error); |
---|
| 60 | if (error) { |
---|
| 61 | g_print ("%s \n", error->message); |
---|
| 62 | g_error_free (error); |
---|
| 63 | error = NULL; |
---|
| 64 | } |
---|
| 65 | dd->interval = MAX (dd->interval, 1); |
---|
| 66 | dd->device_pixmap = panel_applet_gconf_get_int(PANEL_APPLET(dd->applet), "pixmap", NULL); |
---|
| 67 | dd->device_pixmap = CLAMP (dd->device_pixmap, 0, 6); |
---|
| 68 | dd->scale_applet = panel_applet_gconf_get_bool(PANEL_APPLET(dd->applet), "scale", NULL); |
---|
| 69 | dd->auto_eject = panel_applet_gconf_get_bool(PANEL_APPLET(dd->applet), "auto_eject", NULL); |
---|
| 70 | dd->mount_point = panel_applet_gconf_get_string(PANEL_APPLET(dd->applet), "mount_point", NULL); |
---|
| 71 | if (!dd->mount_point) |
---|
| 72 | dd->mount_point = g_strdup ("/mnt/floppy"); |
---|
| 73 | dd->autofs_friendly = panel_applet_gconf_get_bool(PANEL_APPLET(dd->applet), "autofs_friendly", NULL); |
---|
| 74 | dd->custom_icon_in = panel_applet_gconf_get_string(PANEL_APPLET(dd->applet), "custom_icon_mounted", NULL); |
---|
| 75 | dd->custom_icon_out = panel_applet_gconf_get_string(PANEL_APPLET(dd->applet), "custom_icon_unmounted", NULL); |
---|
| 76 | } else { |
---|
| 77 | dd->mount_point = g_strdup("/mnt/floppy"); |
---|
| 78 | dd->interval = 10; |
---|
| 79 | } |
---|
| 80 | g_object_unref (G_OBJECT (client)); |
---|
| 81 | g_free (key); |
---|
| 82 | sync_mount_base(dd); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | static void |
---|
| 86 | cb_mount_activate (GtkEntry *entry, gpointer data) |
---|
| 87 | { |
---|
| 88 | DriveData *dd = data; |
---|
| 89 | gchar *text; |
---|
| 90 | |
---|
| 91 | text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); |
---|
| 92 | |
---|
| 93 | if (!text) |
---|
| 94 | return; |
---|
| 95 | |
---|
| 96 | if (dd->mount_point) { |
---|
| 97 | if (!g_strcasecmp (text, dd->mount_point)) { |
---|
| 98 | g_free (text); |
---|
| 99 | return; |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | g_free(dd->mount_point); |
---|
| 103 | dd->mount_point = g_strdup(text); |
---|
| 104 | |
---|
| 105 | } |
---|
| 106 | else |
---|
| 107 | dd->mount_point = g_strdup(text); |
---|
| 108 | |
---|
| 109 | sync_mount_base (dd); |
---|
| 110 | redraw_pixmap (dd); |
---|
| 111 | panel_applet_gconf_set_string(PANEL_APPLET(dd->applet), "mount_point", |
---|
| 112 | dd->mount_point, NULL); |
---|
| 113 | g_free (text); |
---|
| 114 | |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | static gboolean |
---|
| 118 | cb_mount_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) |
---|
| 119 | { |
---|
| 120 | DriveData *dd = data; |
---|
| 121 | |
---|
| 122 | cb_mount_activate (GTK_ENTRY (widget), dd); |
---|
| 123 | |
---|
| 124 | return FALSE; |
---|
| 125 | |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | static void |
---|
| 129 | spin_changed (GtkSpinButton *button, gpointer data) |
---|
| 130 | { |
---|
| 131 | DriveData *dd = data; |
---|
| 132 | |
---|
| 133 | dd->interval = gtk_spin_button_get_value_as_int(button); |
---|
| 134 | |
---|
| 135 | start_callback_update(dd); |
---|
| 136 | panel_applet_gconf_set_int(PANEL_APPLET(dd->applet), "interval", |
---|
| 137 | dd->interval, NULL); |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | static void |
---|
| 143 | scale_toggled (GtkToggleButton *button, gpointer data) |
---|
| 144 | { |
---|
| 145 | DriveData *dd = data; |
---|
| 146 | |
---|
| 147 | dd->scale_applet = gtk_toggle_button_get_active (button); |
---|
| 148 | redraw_pixmap(dd); |
---|
| 149 | panel_applet_gconf_set_bool(PANEL_APPLET(dd->applet), "scale", |
---|
| 150 | dd->scale_applet, NULL); |
---|
| 151 | |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | static void |
---|
| 155 | eject_toggled (GtkToggleButton *button, gpointer data) |
---|
| 156 | { |
---|
| 157 | DriveData *dd = data; |
---|
| 158 | |
---|
| 159 | dd->auto_eject = gtk_toggle_button_get_active (button); |
---|
| 160 | panel_applet_gconf_set_bool(PANEL_APPLET(dd->applet), "auto_eject", |
---|
| 161 | dd->auto_eject, NULL); |
---|
| 162 | |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | static void |
---|
| 166 | automount_toggled (GtkToggleButton *button, gpointer data) |
---|
| 167 | { |
---|
| 168 | DriveData *dd = data; |
---|
| 169 | |
---|
| 170 | dd->autofs_friendly = gtk_toggle_button_get_active (button); |
---|
| 171 | panel_applet_gconf_set_bool(PANEL_APPLET(dd->applet), "autofs_friendly", |
---|
| 172 | dd->autofs_friendly, NULL); |
---|
| 173 | |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | static void |
---|
| 177 | omenu_changed (GtkOptionMenu *menu, gpointer data) |
---|
| 178 | { |
---|
| 179 | DriveData *dd = data; |
---|
| 180 | gint num; |
---|
| 181 | |
---|
| 182 | num = gtk_option_menu_get_history (menu); |
---|
| 183 | dd->device_pixmap = num < 6 ? num : -1; |
---|
| 184 | |
---|
| 185 | redraw_pixmap(dd); |
---|
| 186 | panel_applet_gconf_set_int(PANEL_APPLET(dd->applet), "pixmap", |
---|
| 187 | dd->device_pixmap, NULL); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | static void |
---|
| 191 | mount_icon_changed (GnomeIconEntry *entry, gpointer data) |
---|
| 192 | { |
---|
| 193 | DriveData *dd = data; |
---|
| 194 | gchar *temp; |
---|
| 195 | |
---|
| 196 | temp = gnome_icon_entry_get_filename(entry); |
---|
| 197 | |
---|
| 198 | if (!temp) |
---|
| 199 | return; |
---|
| 200 | |
---|
| 201 | if(dd->custom_icon_in) |
---|
| 202 | g_free(dd->custom_icon_in); |
---|
| 203 | dd->custom_icon_in = temp; |
---|
| 204 | |
---|
| 205 | dd->device_pixmap = -1; |
---|
| 206 | redraw_pixmap(dd); |
---|
| 207 | panel_applet_gconf_set_string(PANEL_APPLET(dd->applet), "custom_icon_mounted", |
---|
| 208 | dd->custom_icon_in, NULL); |
---|
| 209 | |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | static void |
---|
| 213 | unmount_icon_changed (GnomeIconEntry *entry, gpointer data) |
---|
| 214 | { |
---|
| 215 | DriveData *dd = data; |
---|
| 216 | gchar *temp; |
---|
| 217 | |
---|
| 218 | temp = gnome_icon_entry_get_filename(entry); |
---|
| 219 | |
---|
| 220 | if (!temp) |
---|
| 221 | return; |
---|
| 222 | |
---|
| 223 | if(dd->custom_icon_out) |
---|
| 224 | g_free(dd->custom_icon_out); |
---|
| 225 | dd->custom_icon_out = temp; |
---|
| 226 | |
---|
| 227 | dd->device_pixmap = -1; |
---|
| 228 | redraw_pixmap(dd); |
---|
| 229 | panel_applet_gconf_set_string(PANEL_APPLET(dd->applet), "custom_icon_unmounted", |
---|
| 230 | dd->custom_icon_out, NULL); |
---|
| 231 | |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | void |
---|
| 235 | properties_show (BonoboUIComponent *uic, |
---|
| 236 | DriveData *dd, |
---|
| 237 | const char *verb) |
---|
| 238 | { |
---|
| 239 | GtkWidget *dialog; |
---|
| 240 | GtkWidget *box; |
---|
| 241 | GtkWidget *frame; |
---|
| 242 | GtkWidget *hbox; |
---|
| 243 | GtkWidget *vbox; |
---|
| 244 | GtkWidget *fbox; |
---|
| 245 | GtkWidget *label; |
---|
| 246 | GtkWidget *menu; |
---|
| 247 | GtkWidget *item; |
---|
| 248 | ResponseWidgets *widgets; |
---|
| 249 | gint response; |
---|
| 250 | |
---|
| 251 | widgets = g_new0(ResponseWidgets, 1); |
---|
| 252 | dialog = gtk_dialog_new_with_buttons(_("Disk Mounter Preferences"), NULL, |
---|
| 253 | GTK_DIALOG_DESTROY_WITH_PARENT, |
---|
| 254 | GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
---|
| 255 | NULL); |
---|
| 256 | |
---|
| 257 | box = GTK_DIALOG(dialog)->vbox; |
---|
| 258 | frame = gtk_frame_new(_("Settings")); |
---|
| 259 | gtk_container_set_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); |
---|
| 260 | gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0); |
---|
| 261 | |
---|
| 262 | vbox = gtk_vbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 263 | gtk_container_set_border_width(GTK_CONTAINER(vbox), GNOME_PAD_SMALL); |
---|
| 264 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
---|
| 265 | gtk_widget_show(vbox); |
---|
| 266 | |
---|
| 267 | hbox = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 268 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
---|
| 269 | gtk_widget_show(hbox); |
---|
| 270 | |
---|
| 271 | label = gtk_label_new_with_mnemonic(_("_Mount point:")); |
---|
| 272 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
---|
| 273 | gtk_widget_show(label); |
---|
| 274 | |
---|
| 275 | widgets->mount_entry = gtk_entry_new_with_max_length(255); |
---|
| 276 | gtk_label_set_mnemonic_widget (GTK_LABEL (label), widgets->mount_entry); |
---|
| 277 | gtk_entry_set_text(GTK_ENTRY(widgets->mount_entry), dd->mount_point); |
---|
| 278 | gtk_box_pack_start(GTK_BOX(hbox), widgets->mount_entry , TRUE, TRUE, 0); |
---|
| 279 | gtk_widget_show(widgets->mount_entry); |
---|
| 280 | g_signal_connect (G_OBJECT (widgets->mount_entry), "activate", |
---|
| 281 | G_CALLBACK (cb_mount_activate), dd); |
---|
| 282 | g_signal_connect (G_OBJECT (widgets->mount_entry), "focus_out_event", |
---|
| 283 | G_CALLBACK (cb_mount_focus_out), dd); |
---|
| 284 | |
---|
| 285 | hbox = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 286 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
---|
| 287 | gtk_widget_show(hbox); |
---|
| 288 | |
---|
| 289 | label = gtk_label_new_with_mnemonic(_("_Update interval (seconds):")); |
---|
| 290 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
---|
| 291 | gtk_widget_show(label); |
---|
| 292 | |
---|
| 293 | widgets->update_spin = gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(dd->interval, 1.0, 30.0, 1, 1, 1)), 1, 0); |
---|
| 294 | gtk_label_set_mnemonic_widget (GTK_LABEL (label), widgets->update_spin); |
---|
| 295 | gtk_box_pack_start(GTK_BOX(hbox), widgets->update_spin, FALSE, FALSE, 0); |
---|
| 296 | gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(widgets->update_spin),GTK_UPDATE_ALWAYS); |
---|
| 297 | gtk_widget_show(widgets->update_spin); |
---|
| 298 | g_signal_connect (G_OBJECT (widgets->update_spin), "value_changed", |
---|
| 299 | G_CALLBACK (spin_changed), dd); |
---|
| 300 | |
---|
| 301 | hbox = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 302 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
---|
| 303 | gtk_widget_show(hbox); |
---|
| 304 | |
---|
| 305 | label = gtk_label_new_with_mnemonic(_("_Icon :")); |
---|
| 306 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
---|
| 307 | gtk_widget_show(label); |
---|
| 308 | |
---|
| 309 | widgets->omenu = gtk_option_menu_new (); |
---|
| 310 | gtk_label_set_mnemonic_widget (GTK_LABEL (label), widgets->omenu); |
---|
| 311 | gtk_box_pack_start(GTK_BOX(hbox), widgets->omenu, TRUE, TRUE, 0); |
---|
| 312 | gtk_widget_show(widgets->omenu); |
---|
| 313 | menu = gtk_menu_new(); |
---|
| 314 | gtk_option_menu_set_menu(GTK_OPTION_MENU(widgets->omenu), menu); |
---|
| 315 | g_signal_connect (G_OBJECT (widgets->omenu), "changed", |
---|
| 316 | G_CALLBACK (omenu_changed), dd); |
---|
| 317 | |
---|
| 318 | /* This must be created before the menu items, so we can pass it to a callback */ |
---|
| 319 | fbox = gtk_vbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 320 | gtk_box_pack_start(GTK_BOX(vbox), fbox, FALSE, FALSE, 0); |
---|
| 321 | gtk_widget_show(fbox); |
---|
| 322 | |
---|
| 323 | item = gtk_menu_item_new_with_label(_("Floppy")); |
---|
| 324 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 325 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 326 | item = gtk_menu_item_new_with_label(_("Cdrom")); |
---|
| 327 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 328 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 329 | item = gtk_menu_item_new_with_label(_("Cd Recorder")); |
---|
| 330 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 331 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 332 | item = gtk_menu_item_new_with_label(_("Zip Drive")); |
---|
| 333 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 334 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 335 | item = gtk_menu_item_new_with_label(_("Hard Disk")); |
---|
| 336 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 337 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 338 | item = gtk_menu_item_new_with_label(_("Jaz Drive")); |
---|
| 339 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 340 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_false_cb), fbox); |
---|
| 341 | item = gtk_menu_item_new_with_label(_("Custom")); |
---|
| 342 | gtk_menu_append (GTK_MENU (menu), item); |
---|
| 343 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(set_widget_sensitivity_true_cb), fbox); |
---|
| 344 | |
---|
| 345 | if (dd->device_pixmap == -1) |
---|
| 346 | gtk_option_menu_set_history(GTK_OPTION_MENU(widgets->omenu), 6); |
---|
| 347 | else |
---|
| 348 | gtk_option_menu_set_history(GTK_OPTION_MENU(widgets->omenu), dd->device_pixmap); |
---|
| 349 | |
---|
| 350 | hbox = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 351 | gtk_box_pack_start(GTK_BOX(fbox), hbox, FALSE, FALSE, 0); |
---|
| 352 | gtk_widget_show(hbox); |
---|
| 353 | |
---|
| 354 | widgets->icon_entry_in = gnome_icon_entry_new("drivemount-applet-id-in", _("Select icon for mounted")); |
---|
| 355 | gnome_icon_entry_set_filename(GNOME_ICON_ENTRY(widgets->icon_entry_in), dd->custom_icon_in); |
---|
| 356 | gtk_box_pack_end(GTK_BOX(hbox), widgets->icon_entry_in, FALSE, FALSE, 0); |
---|
| 357 | gtk_widget_show(widgets->icon_entry_in); |
---|
| 358 | g_signal_connect (G_OBJECT (widgets->icon_entry_in), "changed", |
---|
| 359 | G_CALLBACK (mount_icon_changed), dd); |
---|
| 360 | |
---|
| 361 | label = gtk_label_new_with_mnemonic(_("Custom icon for moun_ted:")); |
---|
| 362 | gtk_label_set_mnemonic_widget (GTK_LABEL (label), widgets->icon_entry_in); |
---|
| 363 | gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
---|
| 364 | gtk_widget_show(label); |
---|
| 365 | |
---|
| 366 | hbox = gtk_hbox_new(FALSE, GNOME_PAD_SMALL); |
---|
| 367 | gtk_box_pack_start(GTK_BOX(fbox), hbox, FALSE, FALSE, 0); |
---|
| 368 | gtk_widget_show(hbox); |
---|
| 369 | |
---|
| 370 | widgets->icon_entry_out = gnome_icon_entry_new("drivemount-applet-id-out", _("Select icon for unmounted")); |
---|
| 371 | gnome_icon_entry_set_filename(GNOME_ICON_ENTRY(widgets->icon_entry_out), dd->custom_icon_out); |
---|
| 372 | gtk_box_pack_end(GTK_BOX(hbox), widgets->icon_entry_out, FALSE, FALSE, 0); |
---|
| 373 | gtk_widget_show(widgets->icon_entry_out); |
---|
| 374 | g_signal_connect (G_OBJECT (widgets->icon_entry_out), "changed", |
---|
| 375 | G_CALLBACK (unmount_icon_changed), dd); |
---|
| 376 | |
---|
| 377 | label = gtk_label_new_with_mnemonic(_("Custom icon for not mou_nted:")); |
---|
| 378 | gtk_label_set_mnemonic_widget (GTK_LABEL (label), widgets->icon_entry_out); |
---|
| 379 | gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
---|
| 380 | gtk_widget_show(label); |
---|
| 381 | |
---|
| 382 | if(dd->device_pixmap < 0) |
---|
| 383 | gtk_widget_set_sensitive(fbox, TRUE); |
---|
| 384 | else |
---|
| 385 | gtk_widget_set_sensitive(fbox, FALSE); |
---|
| 386 | |
---|
| 387 | widgets->scale_toggle = gtk_check_button_new_with_mnemonic (_("_Scale size to panel")); |
---|
| 388 | gtk_box_pack_start(GTK_BOX(vbox), widgets->scale_toggle, FALSE, FALSE, 0); |
---|
| 389 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->scale_toggle), dd->scale_applet); |
---|
| 390 | gtk_widget_show(widgets->scale_toggle); |
---|
| 391 | g_signal_connect (G_OBJECT (widgets->scale_toggle), "toggled", |
---|
| 392 | G_CALLBACK (scale_toggled), dd); |
---|
| 393 | |
---|
| 394 | widgets->eject_toggle = gtk_check_button_new_with_mnemonic (_("_Eject on unmount")); |
---|
| 395 | gtk_box_pack_start(GTK_BOX(vbox), widgets->eject_toggle, FALSE, FALSE, 0); |
---|
| 396 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->eject_toggle), dd->auto_eject); |
---|
| 397 | gtk_widget_show(widgets->eject_toggle); |
---|
| 398 | g_signal_connect (G_OBJECT (widgets->eject_toggle), "toggled", |
---|
| 399 | G_CALLBACK (eject_toggled), dd); |
---|
| 400 | |
---|
| 401 | widgets->automount_toggle = gtk_check_button_new_with_mnemonic (_("Use _automount friendly status test")); |
---|
| 402 | gtk_box_pack_start(GTK_BOX(vbox), widgets->automount_toggle, FALSE, FALSE, 0); |
---|
| 403 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->automount_toggle), dd->autofs_friendly); |
---|
| 404 | gtk_widget_show(widgets->automount_toggle); |
---|
| 405 | g_signal_connect (G_OBJECT (widgets->automount_toggle), "toggled", |
---|
| 406 | G_CALLBACK (automount_toggled), dd); |
---|
| 407 | gtk_widget_show_all(frame); |
---|
| 408 | |
---|
| 409 | widgets->dd = dd; |
---|
| 410 | g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(handle_response_cb), widgets); |
---|
| 411 | gtk_widget_show_all(dialog); |
---|
| 412 | } |
---|
| 413 | |
---|
| 414 | static void |
---|
| 415 | handle_response_cb(GtkDialog *dialog, gint response, ResponseWidgets *widgets) |
---|
| 416 | { |
---|
| 417 | gtk_widget_destroy(GTK_WIDGET(dialog)); |
---|
| 418 | g_free(widgets); |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | static void |
---|
| 422 | set_widget_sensitivity_false_cb(GtkWidget *widget, GtkWidget *target) |
---|
| 423 | { |
---|
| 424 | gtk_widget_set_sensitive(target, FALSE); |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | static void |
---|
| 428 | set_widget_sensitivity_true_cb(GtkWidget *widget, GtkWidget *target) |
---|
| 429 | { |
---|
| 430 | gtk_widget_set_sensitive(target, TRUE); |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | static gchar * |
---|
| 434 | remove_level_from_path(const gchar *path) |
---|
| 435 | { |
---|
| 436 | gchar *new_path; |
---|
| 437 | const gchar *ptr; |
---|
| 438 | gint p; |
---|
| 439 | |
---|
| 440 | if (!path) return NULL; |
---|
| 441 | |
---|
| 442 | p = strlen(path) - 1; |
---|
| 443 | if (p < 0) return NULL; |
---|
| 444 | |
---|
| 445 | ptr = path; |
---|
| 446 | while(ptr[p] != '/' && p > 0) p--; |
---|
| 447 | |
---|
| 448 | if (p == 0 && ptr[p] == '/') p++; |
---|
| 449 | new_path = g_strndup(path, (guint)p); |
---|
| 450 | return new_path; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | static void |
---|
| 454 | sync_mount_base(DriveData *dd) |
---|
| 455 | { |
---|
| 456 | g_free(dd->mount_base); |
---|
| 457 | dd->mount_base = remove_level_from_path(dd->mount_point); |
---|
| 458 | } |
---|