Gnome Applet. The my story with drive mount applet.

In my crazy world I think that I must not adapt to operating system and its relative Gui but Os and Gui must adapt to me.
When for example gnome applet doesn't works fine than I would then I download sources, study and change one or two or more time since applet becames right for me.

Then few day ago...

I added in ubuntu the applet called "drive mount" that it enables anyone to mount and to unmout, with a graphical interface, some device like hard disk or removable media.

But when it mounts an device by click relative
icon it is impossible to view if media is effectively mounted.

Now...
Before mounted :
After mounted :

On the contrary if you download sources by :

sudo apt-get source gnome-applets

and you change the file "gnome-applets-x.xx.x/drivemount/drive-button.c" like below :

static gboolean
drive_button_update (gpointer user_data)
{
DriveButton *self;
GdkScreen *screen;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GIcon *icon;
int width, height;
GdkPixbuf *pixbuf = NULL, *scaled, *mountPixbuf;
GtkRequisition button_req, image_req;
char *display_name, *tip;
GError *error = NULL;
g_return_val_if_fail (DRIVE_IS_BUTTON (user_data), FALSE);
self = DRIVE_BUTTON (user_data);
self->update_tag = 0;
drive_button_reset_popup (self);
/* if no volume or mount, unset image */
if (!self->volume && !self->mount) {
if (GTK_BIN (self)->child != NULL)
gtk_image_set_from_pixbuf (GTK_IMAGE (GTK_BIN (self)->child), NULL);
return FALSE;
}
GMount *mount;
if (self->volume) {
display_name = g_volume_get_name (self->volume);
mount = g_volume_get_mount (self->volume);
if (mount)
tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
else
tip = g_strdup_printf ("%s\n%s", display_name, _("(not mounted)"));
if (mount)
icon = g_mount_get_icon (mount);
else
icon = g_volume_get_icon (self->volume);
if (mount)
g_object_unref (mount);
} else {
display_name = g_mount_get_name (self->mount);
tip = g_strdup_printf ("%s\n%s", display_name, _("(mounted)"));
icon = g_mount_get_icon (self->mount);
}
gtk_widget_set_tooltip_text (GTK_WIDGET (self), tip);
g_free (tip);
g_free (display_name);
/* base the icon size on the desired button size */
gtk_widget_size_request (GTK_WIDGET (self), &button_req);
gtk_widget_size_request (GTK_BIN (self)->child, &image_req);
width = self->icon_size - (button_req.width - image_req.width);
height = self->icon_size - (button_req.height - image_req.height);
screen = gtk_widget_get_screen (GTK_WIDGET (self));
icon_theme = gtk_icon_theme_get_for_screen (screen);
icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme, icon,
MIN (width, height),
GTK_ICON_LOOKUP_USE_BUILTIN);
if (icon_info)
{
pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
gtk_icon_info_free (icon_info);
}
g_object_unref (icon);
if (!pixbuf)
return FALSE;
if (mount) {
mountPixbuf = gdk_pixbuf_new_from_file("/usr/share/pixmaps/mount.png", &error);
scaled = gdk_pixbuf_scale_simple (mountPixbuf, width / 3, height / 3, GDK_INTERP_NEAREST);
scaled = gdk_pixbuf_add_alpha(scaled, TRUE, 255, 255, 255);
pixbuf = scaled;
}
scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
if (scaled) {
g_object_unref (pixbuf);
pixbuf = scaled;
}
gtk_image_set_from_pixbuf (GTK_IMAGE (GTK_BIN (self)->child), pixbuf);
g_object_unref (pixbuf);
gtk_widget_size_request (GTK_WIDGET (self), &button_req);
return FALSE;
}
view raw drive-button.c hosted with ❤ by GitHub


Add in /usr/share/pixmaps/ the icon "mount.png"

you can view when media is mounted this icon:

it's tiny example only for your fun!

Nessun commento: