diff options
author | John Ellis <johne@bellatlantic.net> | 1999-05-28 18:36:26 +0000 |
---|---|---|
committer | johne <johne@src.gnome.org> | 1999-05-28 18:36:26 +0000 |
commit | 054e818ba8d9d9ee7406571a6f8d48da43bdcb78 (patch) | |
tree | 08acb7081bcad07691157f11cc06f1969bc7e1ef | |
parent | b9acbf1b86d663b244eac7b2d8fef8ca566a29bc (diff) |
Reorganized code, renamed a few functions. The new "change_size" signal
Fri May 28 14:28:23 1999 John Ellis <johne@bellatlantic.net>
* drivemount.c: Reorganized code, renamed a few functions. The new
"change_size" signal handling is #ifdef 0'd in two places.
* drivemount.h: Default size and max size are defined here.
* properties.c: Changes relating to drivemount.c, above.
-rw-r--r-- | drivemount/ChangeLog | 7 | ||||
-rw-r--r-- | drivemount/drivemount.c | 563 | ||||
-rw-r--r-- | drivemount/drivemount.h | 15 | ||||
-rw-r--r-- | drivemount/properties.c | 21 |
4 files changed, 331 insertions, 275 deletions
diff --git a/drivemount/ChangeLog b/drivemount/ChangeLog index f29db34d9..5ac7d819f 100644 --- a/drivemount/ChangeLog +++ b/drivemount/ChangeLog @@ -1,3 +1,10 @@ +Fri May 28 14:28:23 1999 John Ellis <johne@bellatlantic.net> + + * drivemount.c: Reorganized code, renamed a few functions. The new + "change_size" signal handling is #ifdef 0'd in two places. + * drivemount.h: Default size and max size are defined here. + * properties.c: Changes relating to drivemount.c, above. + Thu May 20 13:50:23 1999 John Ellis <johne@bellatlantic.net> * drivemount.[ch]: Added size hint variable, and use it, now we just diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c index 4834fcd54..e1382a397 100644 --- a/drivemount/drivemount.c +++ b/drivemount/drivemount.c @@ -44,18 +44,27 @@ #include "jazdrive_v_in.xpm" #include "jazdrive_v_out.xpm" -static void about_cb (AppletWidget *widget, gpointer data); -static void browse_cb (AppletWidget *widget, gpointer data); static gint device_is_in_mountlist(DriveData *dd); static dev_t get_device(gchar *file); static gint device_is_mounted(DriveData *dd); -static void update_pixmap(DriveData *dd, gint t); -static gint drive_update_cb(gpointer data); -static gint mount_cb(GtkWidget *widget, gpointer data); + +static void mount_cb(GtkWidget *widget, gpointer data); + +static void about_cb (AppletWidget *widget, gpointer data); static void eject_cb(AppletWidget *applet, gpointer data); +static void browse_cb (AppletWidget *widget, gpointer data); + +static void calculate_icon_size(gint *width, gint *height, DriveData *dd); static void free_pixmaps(DriveData *dd); +static void create_pixmaps(DriveData *dd); +static void update_pixmap(DriveData *dd, gint t); +static void redraw_pixmap(DriveData *dd); + +static gint drive_update_cb(gpointer data); + static void applet_change_orient(GtkWidget *w, PanelOrientType o, gpointer data); static gint applet_save_session(GtkWidget *widget, gchar *privcfgpath, gchar *globcfgpath, gpointer data); + static void destroy_drive_widget(GtkWidget *widget, gpointer data); static DriveData * create_drive_widget(GtkWidget *applet); static GtkWidget * applet_start_new_applet(const gchar *goad_id, const gchar **params, gint nparams); @@ -66,58 +75,6 @@ static void dnd_set_data_cb(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data); static void dnd_init(DriveData *dd); -static void about_cb (AppletWidget *widget, gpointer data) -{ - GtkWidget *about; - const gchar *authors[2]; - gchar version[32]; - - g_snprintf(version, sizeof(version), "%d.%d.%d", - DRIVEMOUNT_APPLET_VERSION_MAJ, - DRIVEMOUNT_APPLET_VERSION_MIN, - DRIVEMOUNT_APPLET_VERSION_REV); - - authors[0] = "John Ellis <johne@bellatlantic.net>"; - authors[1] = NULL; - - about = gnome_about_new ( _("Drive Mount Applet"), version, - "(C) 1999", - authors, - _("Released under the GNU general public license.\n" - "Mounts and Unmounts drives." - "."), - NULL); - gtk_widget_show (about); -} - -static void browse_cb (AppletWidget *widget, gpointer data) -{ - DriveData *dd = data; - const char *buf[2]; - - /* attempt to mount first, otherwise, what is the point? */ - if(!dd->mounted) - { - mount_cb(NULL, dd); - if (!dd->mounted) return; /* failed to mount, so abort */ - } - - buf[0] = dd->mount_point; - buf[1] = NULL; - -/* I assume the first (commented out) call is mor correct, but: - * use "IDL:GNOME/FileManagerWindow:1.0" ? - * how do we correctly construct this string? In the event version != 1.0 ? - */ - -/* goad_server_activate_with_repo_id(NULL, "IDL:GNOME/FileManagerWindow:1.0", - GOAD_ACTIVATE_REMOTE | GOAD_ACTIVATE_ASYNC, buf); -*/ - - goad_server_activate_with_id(NULL, "gmc_filemanager_window", - 0, buf); -} - /* *------------------------------------------------------------------------- * mount status checks @@ -128,11 +85,9 @@ static gint device_is_in_mountlist(DriveData *dd) { FILE *fp; gchar *command_line = "mount"; - gchar buf[201]; + gchar buf[200]; gint found = FALSE; - buf[201] = '\0'; - fp = popen(command_line, "r"); if (!fp) @@ -184,64 +139,206 @@ static gint device_is_mounted(DriveData *dd) /* *------------------------------------------------------------------------- - * image / widget setup and size changes + * mount button press callback *------------------------------------------------------------------------- */ -static void update_pixmap(DriveData *dd, gint t) +static void mount_cb(GtkWidget *widget, gpointer data) { - GdkPixmap *pixmap; - gchar *text; - gchar *tiptext; - if (t) + DriveData *dd = data; + gchar *command_line; + gchar buf[200]; + FILE *fp; + GString *str; + gint check = device_is_mounted(dd); + + if (!check) { - pixmap = GNOME_PIXMAP(dd->pixmap_for_in)->pixmap; - text = _(" mounted"); + command_line = g_strdup_printf("mount %s 2>&1", dd->mount_point); } else { - pixmap = GNOME_PIXMAP(dd->pixmap_for_out)->pixmap; - text = _(" not mounted"); + command_line = g_strdup_printf("umount %s 2>&1", dd->mount_point); } - gtk_pixmap_set(GTK_PIXMAP(dd->button_pixmap), pixmap, NULL); - tiptext = g_strconcat(dd->mount_point,text,NULL); - gtk_tooltips_set_tip (dd->tooltip, dd->applet, tiptext, NULL); - g_free(tiptext); + + fp = popen(command_line, "r"); + + if (!fp) + { + printf("unable to run command: %s\n", command_line); + g_free(command_line); + return; + } + + str = g_string_new(NULL); + + while (fgets(buf, 200, fp) != NULL) + { + gchar *b = buf; + g_string_append(str, b); + } + + pclose (fp); + + /* now if the mount status is the same print + the returned output from (u)mount, we are assuming an error */ + if (check == device_is_mounted(dd)) + { + g_string_prepend(str, _("\" reported:\n")); + g_string_prepend(str, command_line); + g_string_prepend(str, _("Drivemount command failed.\n\"")); + gnome_warning_dialog(str->str); + } + + g_string_free(str, TRUE); + g_free(command_line); + drive_update_cb(dd); } -static void free_pixmaps(DriveData *dd) +/* + *------------------------------------------------------------------------- + * menu callbacks + *------------------------------------------------------------------------- + */ + +static void about_cb (AppletWidget *widget, gpointer data) { - if (dd->pixmap_for_in) gtk_widget_destroy(dd->pixmap_for_in); - if (dd->pixmap_for_out) gtk_widget_destroy(dd->pixmap_for_out); - dd->pixmap_for_in = NULL; - dd->pixmap_for_out = NULL; + GtkWidget *about; + const gchar *authors[2]; + gchar version[32]; + + g_snprintf(version, sizeof(version), "%d.%d.%d", + DRIVEMOUNT_APPLET_VERSION_MAJ, + DRIVEMOUNT_APPLET_VERSION_MIN, + DRIVEMOUNT_APPLET_VERSION_REV); + + authors[0] = "John Ellis <johne@bellatlantic.net>"; + authors[1] = NULL; + + about = gnome_about_new ( _("Drive Mount Applet"), version, + "(C) 1999", + authors, + _("Released under the GNU general public license.\n" + "Mounts and Unmounts drives." + "."), + NULL); + gtk_widget_show (about); } +static void eject_cb(AppletWidget *applet, gpointer data) +{ + DriveData *dd = data; + gchar command_line[300]; + gchar buffer[200]; + gchar dn[100]; /* Devicename */ + gchar mp[100]; /* Mountpoint */ + FILE *ml; /* Mountlist */ -void create_pixmaps(DriveData *dd) + + /* + * Search the output of mount for dd->mount_point + * and use the corresponting device name + * as argument for eject + * if the device is not mounted currently, use + * /etc/fstab for the check + */ + + if (dd->mounted) { + ml = popen("mount", "r"); + while (fgets(buffer, 200, ml)) { + sscanf(buffer, "%s %*s %s", dn, mp); + if (!strcmp(mp, dd->mount_point)) + break; + } + pclose (ml); + } else { + ml = fopen("/etc/fstab", "r"); + while (fgets(buffer, 200, ml)) { + sscanf(buffer, "%s %s", dn, mp); + if (!strcmp(mp, dd->mount_point)) + break; + } + fclose (ml); + } + + if (strcmp(mp, dd->mount_point)) { /* mp != dd->mount_point */ + printf("WARNING: drivemount.c ... dd->mount_point not found in list\ + (output of mount, or /etc/fstab) \n"); + return; + } + + if (dd->mounted) + g_snprintf (command_line, sizeof(command_line), "eject -u %s", dn); + else + g_snprintf (command_line, sizeof(command_line), "eject %s", dn); + + system (command_line); + +} + +static void browse_cb (AppletWidget *widget, gpointer data) { - GtkStyle *style; - char **pmap_d_in; - char **pmap_d_out; + DriveData *dd = data; + const char *buf[2]; - gint width; - gint height; - gint hint = dd->sizehint - 6; /* buttons have border of 3 */ + /* attempt to mount first, otherwise, what is the point? */ + if(!dd->mounted) + { + mount_cb(NULL, dd); + if (!dd->mounted) return; /* failed to mount, so abort */ + } + + buf[0] = dd->mount_point; + buf[1] = NULL; + + /* open the filemanager window */ + goad_server_activate_with_repo_id(NULL, "IDL:GNOME/FileManagerWindow:1.0", + GOAD_ACTIVATE_REMOTE | GOAD_ACTIVATE_ASYNC, buf); +} + +/* + *------------------------------------------------------------------------- + * icon button/pixmap setup and size changes + *------------------------------------------------------------------------- + */ - if (hint > PIXMAP_WIDTH) hint = PIXMAP_WIDTH; /* maximum size is 40, ignore larger sizes */ +static void calculate_icon_size(gint *width, gint *height, DriveData *dd) +{ + gint hint; + + /* buttons have border of 3, a panel less than 8 pixels wide? never. */ + hint = dd->sizehint - 6; + + if (hint > SIZEHINT_MAX) hint = SIZEHINT_MAX; /* calculate the size */ if (dd->orient == ORIENT_LEFT || dd->orient == ORIENT_RIGHT) { - width = hint; - height = (float)hint / PIXMAP_WIDTH * PIXMAP_HEIGHT; + *width = hint; + *height = (float)hint / ICON_WIDTH * ICON_HEIGHT; } else { - width = (float)hint / PIXMAP_WIDTH * PIXMAP_HEIGHT; - height = hint; + *width = (float)hint / ICON_WIDTH * ICON_HEIGHT; + *height = hint; } +} + +static void free_pixmaps(DriveData *dd) +{ + if (dd->pixmap_for_in) gtk_widget_destroy(dd->pixmap_for_in); + if (dd->pixmap_for_out) gtk_widget_destroy(dd->pixmap_for_out); + dd->pixmap_for_in = NULL; + dd->pixmap_for_out = NULL; +} +static void create_pixmaps(DriveData *dd) +{ + GtkStyle *style; + char **pmap_d_in; + char **pmap_d_out; + gint width; + gint height; if (dd->orient == ORIENT_LEFT || dd->orient == ORIENT_RIGHT) { @@ -304,15 +401,38 @@ void create_pixmaps(DriveData *dd) } } - style = gtk_widget_get_style(dd->applet); free_pixmaps(dd); + calculate_icon_size(&width, &height, dd); + style = gtk_widget_get_style(dd->applet); + dd->pixmap_for_in = gnome_pixmap_new_from_xpm_d_at_size(pmap_d_in, width, height); dd->pixmap_for_out = gnome_pixmap_new_from_xpm_d_at_size(pmap_d_out, width, height); } -void redraw_pixmap(DriveData *dd) +static void update_pixmap(DriveData *dd, gint t) +{ + GdkPixmap *pixmap; + gchar *text; + gchar *tiptext; + if (t) + { + pixmap = GNOME_PIXMAP(dd->pixmap_for_in)->pixmap; + text = _(" mounted"); + } + else + { + pixmap = GNOME_PIXMAP(dd->pixmap_for_out)->pixmap; + text = _(" not mounted"); + } + gtk_pixmap_set(GTK_PIXMAP(dd->button_pixmap), pixmap, NULL); + tiptext = g_strconcat(dd->mount_point,text,NULL); + gtk_tooltips_set_tip (dd->tooltip, dd->applet, tiptext, NULL); + g_free(tiptext); +} + +static void redraw_pixmap(DriveData *dd) { if (!device_is_mounted(dd)) { @@ -326,28 +446,21 @@ void redraw_pixmap(DriveData *dd) } } -static void reset_sizes(DriveData *dd) +void reset_icon(DriveData *dd) { gint width; gint height; - gint hint = dd->sizehint - 6; /* buttons have border of 3 */ - if (hint > PIXMAP_WIDTH) hint = PIXMAP_WIDTH; /* maximum size is 40, ignore larger sizes */ + /* do nothing with startup signals */ + if (!dd->button_pixmap) return; - /* calculate the size */ - if (dd->orient == ORIENT_LEFT || dd->orient == ORIENT_RIGHT) - { - width = hint; - height = (float)hint / PIXMAP_WIDTH * PIXMAP_HEIGHT; - } - else - { - width = (float)hint / PIXMAP_WIDTH * PIXMAP_HEIGHT; - height = hint; - } + calculate_icon_size(&width, &height, dd); + gtk_widget_set_usize(dd->button, width + 6, height + 6); - gtk_widget_set_usize(dd->button,width + 6, height + 6); + create_pixmaps(dd); + redraw_pixmap(dd); } + /* *------------------------------------------------------------------------- * main callback loop @@ -380,142 +493,37 @@ static gint drive_update_cb(gpointer data) return TRUE; } -/* - *------------------------------------------------------------------------- - * mount calls - *------------------------------------------------------------------------- - */ - -static gint mount_cb(GtkWidget *widget, gpointer data) +/* start or change the update callback timeout interval */ +void start_callback_update(DriveData *dd) { - DriveData *dd = data; - gchar command_line[300]; - gchar buf[200]; - FILE *fp; - GString *str; - gint check = device_is_mounted(dd); - - if (!check) - g_snprintf(command_line, sizeof(command_line), - "mount %s 2>&1", dd->mount_point); - else - g_snprintf(command_line, sizeof(command_line), - "umount %s 2>&1", dd->mount_point); - - fp = popen(command_line, "r"); - - if (!fp) - { - printf("unable to run command: %s\n", command_line); - return FALSE; - } - - str = g_string_new(NULL); - - while (fgets(buf, 200, fp) != NULL) - { - gchar *b = buf; - g_string_append(str, b); - } - - pclose (fp); - - /* now if the mount status is the same print - the returned output from (u)mount, we are assuming an error */ - if (check == device_is_mounted(dd)) - { - g_string_prepend(str, _("\" reported:\n")); - g_string_prepend(str, command_line); - g_string_prepend(str, _("Drivemount command failed.\n\"")); - gnome_warning_dialog(str->str); - } - - g_string_free(str, TRUE); - drive_update_cb(dd); - return FALSE; + gint delay; + delay = dd->interval * 1000; + if (dd->timeout_id) gtk_timeout_remove(dd->timeout_id); + dd->timeout_id = gtk_timeout_add(delay, (GtkFunction)drive_update_cb, dd); } -static void eject_cb(AppletWidget *applet, gpointer data) -{ - DriveData *dd = data; - gchar command_line[300]; - gchar buffer[200]; - gchar dn[100]; /* Devicename */ - gchar mp[100]; /* Mountpoint */ - FILE *ml; /* Mountlist */ - - - /* - * Search the output of mount for dd->mount_point - * and use the corresponting device name - * as argument for eject - * if the device is not mounted currently, use - * /etc/fstab for the check - */ - - if (dd->mounted) { - ml = popen("mount", "r"); - while (fgets(buffer, 200, ml)) { - sscanf(buffer, "%s %*s %s", dn, mp); - if (!strcmp(mp, dd->mount_point)) - break; - } - pclose (ml); - } else { - ml = fopen("/etc/fstab", "r"); - while (fgets(buffer, 200, ml)) { - sscanf(buffer, "%s %s", dn, mp); - if (!strcmp(mp, dd->mount_point)) - break; - } - fclose (ml); - } - - if (strcmp(mp, dd->mount_point)) { /* mp != dd->mount_point */ - printf("WARNING: drivemount.c ... dd->mount_point not found in list\ - (output of mount, or /etc/fstab) \n"); - return; - } - - if (dd->mounted) - g_snprintf (command_line, sizeof(command_line), "eject -u %s", dn); - else - g_snprintf (command_line, sizeof(command_line), "eject %s", dn); - - system (command_line); - - - return; - -} - /* *------------------------------------------------------------------------- - * startup and (re)initialization + * applet signals *------------------------------------------------------------------------- */ -/* start or change the update callback timeout interval */ -void start_callback_update(DriveData *dd) +#ifdef 0 +static void applet_change_size(GtkWidget *w, PanelSizeType size, gpointer data) { - gint delay; - delay = dd->interval * 1000; - if (dd->timeout_id) gtk_timeout_remove(dd->timeout_id); - dd->timeout_id = gtk_timeout_add(delay, (GtkFunction)drive_update_cb, dd); + DriveData *dd = data; + dd->sizehint = (gint)size; + reset_icon(dd); } +#endif static void applet_change_orient(GtkWidget *w, PanelOrientType o, gpointer data) { - /* resize the applet and set the proper pixmaps */ DriveData *dd = data; dd->orient = o; - create_pixmaps(dd); - - reset_sizes(dd); - - redraw_pixmap(dd); + reset_icon(dd); } static gint applet_save_session(GtkWidget *widget, gchar *privcfgpath, gchar *globcfgpath, gpointer data) @@ -525,6 +533,12 @@ static gint applet_save_session(GtkWidget *widget, gchar *privcfgpath, gchar *gl return FALSE; } +/* + *------------------------------------------------------------------------- + * initialization and destruction + *------------------------------------------------------------------------- + */ + static void destroy_drive_widget(GtkWidget *widget, gpointer data) { DriveData *dd = data; @@ -538,60 +552,59 @@ static DriveData * create_drive_widget(GtkWidget *applet) { DriveData *dd; gchar *tmp_path; + gint width; + gint height; dd = g_new(DriveData, 1); dd->applet = applet; dd->orient = ORIENT_UP; + dd->sizehint = SIZEHINT_DEFAULT; dd->device_pixmap = 0; dd->mount_point = NULL; dd->propwindow = NULL; dd->mount_base = g_strdup("/mnt"); dd->autofs_friendly = FALSE; - dd->sizehint = DEFAULT_SIZE_HINT; /* this is wher we play/test the sizing code. */ + dd->pixmap_for_in = NULL; + dd->pixmap_for_out = NULL; property_load(APPLET_WIDGET(applet)->privcfgpath, dd); - dd->button=gtk_button_new(); + dd->button = gtk_button_new(); gtk_signal_connect(GTK_OBJECT(applet),"destroy", - GTK_SIGNAL_FUNC(destroy_drive_widget), - dd); + GTK_SIGNAL_FUNC(destroy_drive_widget), dd); gtk_signal_connect(GTK_OBJECT(dd->button),"clicked", - GTK_SIGNAL_FUNC(mount_cb), - dd); + GTK_SIGNAL_FUNC(mount_cb), dd); dnd_init(dd); gtk_widget_show(dd->button); - dd->tooltip=gtk_tooltips_new(); + dd->button_pixmap = NULL; /* will be created later */ - gtk_widget_realize(dd->applet); + dd->tooltip = gtk_tooltips_new(); - dd->pixmap_for_in = NULL; - dd->pixmap_for_out = NULL; - create_pixmaps(dd); + /* attach applet signals */ - dd->button_pixmap = gtk_pixmap_new(GNOME_PIXMAP(dd->pixmap_for_out)->pixmap, NULL); - gtk_container_add(GTK_CONTAINER(dd->button), dd->button_pixmap); - gtk_widget_show(dd->button_pixmap); - - redraw_pixmap(dd); - -/* attach applet signals here */ +#ifdef 0 + /* + * APPLET SCALING SIGNAL SHOULD BE CONNECTED HERE, SOMEWHERE, I GUESS + * perhaps it should be a signal similar to change_orient, but include + * the size hint as well. (the applet should then be smart enough to figure + * if the size hint is for it's width or height + * note: please look at the current orient callback to see what needs to be + * called to set the new size of the applet after setting dd->sizehint. + */ + gtk_signal_connect(GTK_OBJECT(applet),"change_size", + GTK_SIGNAL_FUNC(applet_change_size), dd); +#endif -/* APPLET SCALING SIGNAL SHOULD BE CONNECTED HERE, SOMEWHERE, I GUESS - * perhaps it should be a signal similar to change_orient, but include - * the size hint as well. (the applet should then be smart enough to figure - * if the size hint is for it's width or height - * note: please look at the current orient callback to see what needs to be - * called to set the new size of the applet after setting dd->sizehint. - */ gtk_signal_connect(GTK_OBJECT(applet),"change_orient", - GTK_SIGNAL_FUNC(applet_change_orient), - dd); + GTK_SIGNAL_FUNC(applet_change_orient), dd); gtk_signal_connect(GTK_OBJECT(applet),"save_session", - GTK_SIGNAL_FUNC(applet_save_session), - dd); + GTK_SIGNAL_FUNC(applet_save_session), dd); + + /* attach applet menus */ + applet_widget_register_stock_callback(APPLET_WIDGET(applet), "properties", GNOME_STOCK_MENU_PROP, @@ -623,7 +636,28 @@ static DriveData * create_drive_widget(GtkWidget *applet) browse_cb, dd); + applet_widget_add(APPLET_WIDGET(applet), dd->button); + + gtk_widget_realize(dd->applet); + gtk_widget_show(applet); + + /* + * We should have the start-up size attributes after + * the above showing of the applet, finish up. + * (because the orient/size handlers are called upon gtk_widget_show) + */ + + calculate_icon_size(&width, &height, dd); + gtk_widget_set_usize(dd->button, width + 6, height + 6); + + create_pixmaps(dd); + dd->button_pixmap = gtk_pixmap_new(GNOME_PIXMAP(dd->pixmap_for_out)->pixmap, NULL); + gtk_container_add(GTK_CONTAINER(dd->button), dd->button_pixmap); + gtk_widget_show(dd->button_pixmap); + redraw_pixmap(dd); + start_callback_update(dd); + return dd; } @@ -636,12 +670,11 @@ static GtkWidget * applet_start_new_applet(const gchar *goad_id, const gchar **p applet = applet_widget_new(goad_id); if (!applet) + { g_error("Can't create applet!\n"); + } dd = create_drive_widget(applet); - - applet_widget_add(APPLET_WIDGET(applet), dd->button); - gtk_widget_show(applet); return applet; } @@ -662,16 +695,16 @@ int main (int argc, char *argv[]) goad_id = (char *)goad_server_activation_id(); - if(goad_id && !strcmp(goad_id, "drivemount_applet")) { + if(goad_id && !strcmp(goad_id, "drivemount_applet")) + { applet = applet_widget_new("drivemount_applet"); if (!applet) - g_error("Can't create applet!\n"); + { + g_error("Can't create applet!\n"); + } dd = create_drive_widget(applet); - - applet_widget_add(APPLET_WIDGET(applet), dd->button); - gtk_widget_show(applet); - } + } applet_widget_gtk_main(); return 0; diff --git a/drivemount/drivemount.h b/drivemount/drivemount.h index 2625ac580..cac1dda31 100644 --- a/drivemount/drivemount.h +++ b/drivemount/drivemount.h @@ -16,12 +16,16 @@ #define DRIVEMOUNT_APPLET_VERSION_MAJ 1 #define DRIVEMOUNT_APPLET_VERSION_MIN 0 -#define DRIVEMOUNT_APPLET_VERSION_REV 1 +#define DRIVEMOUNT_APPLET_VERSION_REV 2 -#define PIXMAP_HEIGHT 10 -#define PIXMAP_WIDTH 40 +#define ICON_HEIGHT 10 +#define ICON_WIDTH 40 -#define DEFAULT_SIZE_HINT 24 +#define SIZEHINT_DEFAULT 46 +#define SIZEHINT_MAX 80 /* Set this to 46 to disable scaling larger + * than the default size, but still allow + * scaling smaller. + */ typedef struct _DriveData DriveData; struct _DriveData @@ -53,8 +57,7 @@ struct _DriveData }; -void create_pixmaps(DriveData *dd); -void redraw_pixmap(DriveData *dd); +void reset_icon(DriveData *dd); void start_callback_update(DriveData *dd); void property_load(gchar *path, DriveData *dd); diff --git a/drivemount/properties.c b/drivemount/properties.c index 673f3ce86..1fe5e04f8 100644 --- a/drivemount/properties.c +++ b/drivemount/properties.c @@ -94,18 +94,31 @@ static void update_delay_cb( GtkWidget *widget, gpointer data ) static void property_apply_cb( GtkWidget *widget, void *data, DriveData *dd) { + gint changed = FALSE; gchar *new_file; + dd->autofs_friendly = dd->prop_autofs_friendly; + new_file = gtk_entry_get_text(GTK_ENTRY(dd->mount_point_entry)); - if (dd->mount_point) g_free(dd->mount_point); - dd->mount_point = strdup(new_file); + if (dd->mount_point && strcmp(dd->mount_point, new_file) == 0) + { + changed = TRUE; + } + g_free(dd->mount_point); + dd->mount_point = g_strdup(new_file); + dd->interval = dd->prop_interval; if (dd->device_pixmap != dd->prop_device_pixmap) { dd->device_pixmap = dd->prop_device_pixmap; - create_pixmaps(dd); + changed = TRUE; } - redraw_pixmap(dd); + + if (changed) + { + reset_icon(dd); + } + start_callback_update(dd); /*make the panel save our config*/ |