summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2020-11-25 22:32:37 +0100
committerRobert Antoni Buj Gelonch <[email protected]>2020-11-27 21:23:07 +0100
commit48b8a559dfab8ea52a14d26bf54a8c93e0937101 (patch)
tree5a908fc4632975051f6e153f1e6f6d5198dd4622
parent76fb110abce4f7337f06b16446c38fb8136c02d2 (diff)
downloadmate-applets-48b8a559dfab8ea52a14d26bf54a8c93e0937101.tar.bz2
mate-applets-48b8a559dfab8ea52a14d26bf54a8c93e0937101.tar.xz
drivemount: improve code-style
- tabs to spaces - 4 spaces at the beginning of a line
-rw-r--r--drivemount/drive-button.c698
-rw-r--r--drivemount/drive-button.h4
-rw-r--r--drivemount/drive-list.c384
-rw-r--r--drivemount/drive-list.h6
-rw-r--r--drivemount/drivemount.c203
5 files changed, 653 insertions, 642 deletions
diff --git a/drivemount/drive-button.c b/drivemount/drive-button.c
index 59d8c86d..f64f38c4 100644
--- a/drivemount/drive-button.c
+++ b/drivemount/drive-button.c
@@ -41,12 +41,12 @@ enum {
};
/* type registration boilerplate code */
-G_DEFINE_TYPE(DriveButton, drive_button, GTK_TYPE_BUTTON)
+G_DEFINE_TYPE (DriveButton, drive_button, GTK_TYPE_BUTTON)
static void drive_button_set_volume (DriveButton *self,
- GVolume *volume);
+ GVolume *volume);
static void drive_button_set_mount (DriveButton *self,
- GMount *mount);
+ GMount *mount);
static void drive_button_reset_popup (DriveButton *self);
static void drive_button_ensure_popup (DriveButton *self);
@@ -55,18 +55,18 @@ static void drive_button_dispose (GObject *object);
static void drive_button_unrealize (GtkWidget *widget);
#endif /* 0 */
static gboolean drive_button_button_press (GtkWidget *widget,
- GdkEventButton *event);
+ GdkEventButton *event);
static gboolean drive_button_key_press (GtkWidget *widget,
- GdkEventKey *event);
+ GdkEventKey *event);
static void drive_button_theme_change (GtkIconTheme *icon_theme,
- gpointer data);
+ gpointer data);
static void
drive_button_class_init (DriveButtonClass *class)
{
- G_OBJECT_CLASS(class)->dispose = drive_button_dispose;
- GTK_WIDGET_CLASS(class)->button_press_event = drive_button_button_press;
- GTK_WIDGET_CLASS(class)->key_press_event = drive_button_key_press;
+ G_OBJECT_CLASS (class)->dispose = drive_button_dispose;
+ GTK_WIDGET_CLASS (class)->button_press_event = drive_button_button_press;
+ GTK_WIDGET_CLASS (class)->key_press_event = drive_button_key_press;
GtkCssProvider *provider;
@@ -80,7 +80,7 @@ drive_button_class_init (DriveButtonClass *class)
"}",
-1, NULL);
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default(),
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
@@ -93,7 +93,7 @@ drive_button_init (DriveButton *self)
image = gtk_image_new ();
gtk_container_add (GTK_CONTAINER (self), image);
- gtk_widget_show(image);
+ gtk_widget_show (image);
self->volume = NULL;
self->mount = NULL;
@@ -144,39 +144,39 @@ drive_button_dispose (GObject *object)
drive_button_set_volume (self, NULL);
if (self->update_tag)
- g_source_remove (self->update_tag);
+ g_source_remove (self->update_tag);
self->update_tag = 0;
drive_button_reset_popup (self);
if (G_OBJECT_CLASS (drive_button_parent_class)->dispose)
- (* G_OBJECT_CLASS (drive_button_parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (drive_button_parent_class)->dispose) (object);
}
static gboolean
drive_button_button_press (GtkWidget *widget,
- GdkEventButton *event)
+ GdkEventButton *event)
{
DriveButton *self = DRIVE_BUTTON (widget);
/* don't consume non-button1 presses */
if (event->button == 1) {
- drive_button_ensure_popup (self);
- if (self->popup_menu) {
- gtk_menu_popup_at_widget (GTK_MENU (self->popup_menu),
- widget,
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- (const GdkEvent*) event);
- }
- return TRUE;
+ drive_button_ensure_popup (self);
+ if (self->popup_menu) {
+ gtk_menu_popup_at_widget (GTK_MENU (self->popup_menu),
+ widget,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent*) event);
+ }
+ return TRUE;
}
return FALSE;
}
static gboolean
drive_button_key_press (GtkWidget *widget,
- GdkEventKey *event)
+ GdkEventKey *event)
{
DriveButton *self = DRIVE_BUTTON (widget);
@@ -185,61 +185,64 @@ drive_button_key_press (GtkWidget *widget,
case GDK_KEY_space:
case GDK_KEY_KP_Enter:
case GDK_KEY_Return:
- drive_button_ensure_popup (self);
- if (self->popup_menu) {
- gtk_menu_popup_at_widget (GTK_MENU (self->popup_menu),
- widget,
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- (const GdkEvent*) event);
- }
- return TRUE;
+ drive_button_ensure_popup (self);
+ if (self->popup_menu) {
+ gtk_menu_popup_at_widget (GTK_MENU (self->popup_menu),
+ widget,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent*) event);
+ }
+ return TRUE;
}
return FALSE;
}
static void
-drive_button_theme_change (GtkIconTheme *icon_theme, gpointer data)
+drive_button_theme_change (GtkIconTheme *icon_theme,
+ gpointer data)
{
drive_button_queue_update (data);
}
static void
-drive_button_set_volume (DriveButton *self, GVolume *volume)
+drive_button_set_volume (DriveButton *self,
+ GVolume *volume)
{
g_return_if_fail (DRIVE_IS_BUTTON (self));
if (self->volume) {
- g_object_unref (self->volume);
+ g_object_unref (self->volume);
}
self->volume = NULL;
if (self->mount) {
- g_object_unref (self->mount);
+ g_object_unref (self->mount);
}
self->mount = NULL;
if (volume) {
- self->volume = g_object_ref (volume);
+ self->volume = g_object_ref (volume);
}
drive_button_queue_update (self);
}
static void
-drive_button_set_mount (DriveButton *self, GMount *mount)
+drive_button_set_mount (DriveButton *self,
+ GMount *mount)
{
g_return_if_fail (DRIVE_IS_BUTTON (self));
if (self->volume) {
- g_object_unref (self->volume);
+ g_object_unref (self->volume);
}
self->volume = NULL;
if (self->mount) {
- g_object_unref (self->mount);
+ g_object_unref (self->mount);
}
self->mount = NULL;
if (mount) {
- self->mount = g_object_ref (mount);
+ self->mount = g_object_ref (mount);
}
drive_button_queue_update (self);
}
@@ -418,64 +421,66 @@ void
drive_button_queue_update (DriveButton *self)
{
if (!self->update_tag) {
- self->update_tag = g_idle_add (drive_button_update, self);
+ self->update_tag = g_idle_add (drive_button_update, self);
}
}
void
-drive_button_set_size (DriveButton *self, int icon_size)
+drive_button_set_size (DriveButton *self,
+ int icon_size)
{
g_return_if_fail (DRIVE_IS_BUTTON (self));
if (self->icon_size != icon_size) {
- self->icon_size = icon_size;
- drive_button_queue_update (self);
+ self->icon_size = icon_size;
+ drive_button_queue_update (self);
}
}
void
-drive_button_redraw (gpointer key, gpointer value, gpointer user_data)
+drive_button_redraw (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
DriveButton *button = value;
drive_button_queue_update (button);
}
int
-drive_button_compare (DriveButton *button, DriveButton *other_button)
+drive_button_compare (DriveButton *button,
+ DriveButton *other_button)
{
/* sort drives before driveless volumes volumes */
if (button->volume) {
- if (other_button->volume)
- {
- int cmp;
- gchar *str1, *str2;
-
- str1 = g_volume_get_name (button->volume);
- str2 = g_volume_get_name (other_button->volume);
- cmp = g_utf8_collate (str1, str2);
- g_free (str2);
- g_free (str1);
-
- return cmp;
- } else {
- return -1;
- }
+ if (other_button->volume) {
+ int cmp;
+ gchar *str1, *str2;
+
+ str1 = g_volume_get_name (button->volume);
+ str2 = g_volume_get_name (other_button->volume);
+ cmp = g_utf8_collate (str1, str2);
+ g_free (str2);
+ g_free (str1);
+
+ return cmp;
+ } else {
+ return -1;
+ }
} else {
- if (other_button->volume)
- {
- return 1;
- } else {
- int cmp;
- gchar *str1, *str2;
-
- str1 = g_mount_get_name (button->mount);
- str2 = g_mount_get_name (other_button->mount);
- cmp = g_utf8_collate (str1, str2);
- g_free (str2);
- g_free (str1);
-
- return cmp;
- }
+ if (other_button->volume) {
+ return 1;
+ } else {
+ int cmp;
+ gchar *str1, *str2;
+
+ str1 = g_mount_get_name (button->mount);
+ str2 = g_mount_get_name (other_button->mount);
+ cmp = g_utf8_collate (str1, str2);
+ g_free (str2);
+ g_free (str1);
+
+ return cmp;
+ }
}
}
@@ -483,7 +488,7 @@ static void
drive_button_reset_popup (DriveButton *self)
{
if (self->popup_menu)
- gtk_widget_destroy (GTK_WIDGET (self->popup_menu));
+ gtk_widget_destroy (GTK_WIDGET (self->popup_menu));
self->popup_menu = NULL;
}
@@ -504,42 +509,45 @@ escape_underscores (const char *str)
/* count up how many underscores are in the string */
count = 0;
for (i = 0; str[i] != '\0'; i++) {
- if (str[i] == '_')
- count++;
+ if (str[i] == '_')
+ count++;
}
/* copy to new string, doubling up underscores */
new_str = g_new (char, i + count + 1);
for (i = j = 0; str[i] != '\0'; i++, j++) {
- new_str[j] = str[i];
- if (str[i] == '_')
- new_str[++j] = '_';
+ new_str[j] = str[i];
+ if (str[i] == '_')
+ new_str[++j] = '_';
}
new_str[j] = '\0';
return new_str;
}
static GtkWidget *
-create_menu_item (DriveButton *self, const gchar *icon_name,
- const gchar *label, GCallback callback,
- gboolean sensitive)
+create_menu_item (DriveButton *self,
+ const gchar *icon_name,
+ const gchar *label,
+ GCallback callback,
+ gboolean sensitive)
{
GtkWidget *item, *image;
item = gtk_image_menu_item_new_with_mnemonic (label);
if (icon_name) {
- image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
}
if (callback)
- g_signal_connect_object (item, "activate", callback, self,
- G_CONNECT_SWAPPED);
+ g_signal_connect_object (item, "activate", callback, self,
+ G_CONNECT_SWAPPED);
gtk_widget_set_sensitive (item, sensitive);
gtk_widget_show (item);
return item;
}
static void
-open_drive (DriveButton *self, GtkWidget *item)
+open_drive (DriveButton *self,
+ GtkWidget *item)
{
GdkScreen *screen;
GtkWidget *dialog;
@@ -550,54 +558,54 @@ open_drive (DriveButton *self, GtkWidget *item)
GAppInfo *app_info;
if (self->volume) {
- GMount *mount;
+ GMount *mount;
- mount = g_volume_get_mount (self->volume);
- if (mount) {
- file = g_mount_get_root (mount);
- g_object_unref(mount);
- }
+ mount = g_volume_get_mount (self->volume);
+ if (mount) {
+ file = g_mount_get_root (mount);
+ g_object_unref (mount);
+ }
} else if (self->mount) {
- file = g_mount_get_root (self->mount);
+ file = g_mount_get_root (self->mount);
} else
- g_return_if_reached();
+ g_return_if_reached ();
- app_info = g_app_info_get_default_for_type("inode/directory", FALSE);
+ app_info = g_app_info_get_default_for_type ("inode/directory", FALSE);
if (!app_info)
app_info = G_APP_INFO (g_desktop_app_info_new ("caja.desktop"));
if (app_info) {
- GdkDisplay *display = gtk_widget_get_display (item);
- launch_context = gdk_display_get_app_launch_context (display);
- screen = gtk_widget_get_screen (GTK_WIDGET (self));
- gdk_app_launch_context_set_screen (launch_context, screen);
- files = g_list_prepend (files, file);
- g_app_info_launch (app_info,
- files,
- G_APP_LAUNCH_CONTEXT (launch_context),
- &error);
-
- g_object_unref (launch_context);
- g_list_free (files);
+ GdkDisplay *display = gtk_widget_get_display (item);
+ launch_context = gdk_display_get_app_launch_context (display);
+ screen = gtk_widget_get_screen (GTK_WIDGET (self));
+ gdk_app_launch_context_set_screen (launch_context, screen);
+ files = g_list_prepend (files, file);
+ g_app_info_launch (app_info,
+ files,
+ G_APP_LAUNCH_CONTEXT (launch_context),
+ &error);
+
+ g_object_unref (launch_context);
+ g_list_free (files);
}
if (!app_info || error) {
- dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("Cannot execute Caja"));
- if (error)
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
- else
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "Could not find Caja");
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_widget_show (dialog);
- g_error_free (error);
+ dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Cannot execute Caja"));
+ if (error)
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+ else
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "Could not find Caja");
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dialog);
+ g_error_free (error);
}
- g_object_unref(file);
+ g_object_unref (file);
}
/* copied from mate-volume-manager/src/manager.c maybe there is a better way than
@@ -608,52 +616,54 @@ open_drive (DriveButton *self, GtkWidget *item)
* and %m with the given path
*/
static void
-gvm_run_command (const char *device, const char *command, const char *path)
-{
- char *argv[4];
- gchar *new_command;
- GError *error = NULL;
- GString *exec = g_string_new (NULL);
- char *p, *q;
-
- /* perform s/%d/device/ and s/%m/path/ */
- new_command = g_strdup (command);
- q = new_command;
- p = new_command;
- while ((p = strchr (p, '%')) != NULL) {
- if (*(p + 1) == 'd') {
- *p = '\0';
- g_string_append (exec, q);
- g_string_append (exec, device);
- q = p + 2;
- p = p + 2;
- } else if (*(p + 1) == 'm') {
- *p = '\0';
- g_string_append (exec, q);
- g_string_append (exec, path);
- q = p + 2;
- p = p + 2;
- } else {
- /* Ignore anything else. */
- p++;
- }
- }
- g_string_append (exec, q);
-
- argv[0] = "/bin/sh";
- argv[1] = "-c";
- argv[2] = exec->str;
- argv[3] = NULL;
-
- g_spawn_async (g_get_home_dir (), argv, NULL, 0, NULL, NULL,
- NULL, &error);
- if (error) {
- g_warning ("failed to exec %s: %s\n", exec->str, error->message);
- g_error_free (error);
- }
-
- g_string_free (exec, TRUE);
- g_free (new_command);
+gvm_run_command (const char *device,
+ const char *command,
+ const char *path)
+{
+ char *argv[4];
+ gchar *new_command;
+ GError *error = NULL;
+ GString *exec = g_string_new (NULL);
+ char *p, *q;
+
+ /* perform s/%d/device/ and s/%m/path/ */
+ new_command = g_strdup (command);
+ q = new_command;
+ p = new_command;
+ while ((p = strchr (p, '%')) != NULL) {
+ if (*(p + 1) == 'd') {
+ *p = '\0';
+ g_string_append (exec, q);
+ g_string_append (exec, device);
+ q = p + 2;
+ p = p + 2;
+ } else if (*(p + 1) == 'm') {
+ *p = '\0';
+ g_string_append (exec, q);
+ g_string_append (exec, path);
+ q = p + 2;
+ p = p + 2;
+ } else {
+ /* Ignore anything else. */
+ p++;
+ }
+ }
+ g_string_append (exec, q);
+
+ argv[0] = "/bin/sh";
+ argv[1] = "-c";
+ argv[2] = exec->str;
+ argv[3] = NULL;
+
+ g_spawn_async (g_get_home_dir (), argv, NULL, 0, NULL, NULL,
+ NULL, &error);
+ if (error) {
+ g_warning ("failed to exec %s: %s\n", exec->str, error->message);
+ g_error_free (error);
+ }
+
+ g_string_free (exec, TRUE);
+ g_free (new_command);
}
/*
@@ -665,208 +675,220 @@ gvm_run_command (const char *device, const char *command, const char *path)
* gvm_check_dvd_only)
*/
static gboolean
-gvm_check_dvd_only (const char *udi, const char *device, const char *mount_point)
-{
- char *path;
- gboolean retval;
-
- path = g_build_path (G_DIR_SEPARATOR_S, mount_point, "video_ts", NULL);
- retval = g_file_test (path, G_FILE_TEST_IS_DIR);
- g_free (path);
-
- /* try the other name, if needed */
- if (retval == FALSE) {
- path = g_build_path (G_DIR_SEPARATOR_S, mount_point,
- "VIDEO_TS", NULL);
- retval = g_file_test (path, G_FILE_TEST_IS_DIR);
- g_free (path);
- }
+gvm_check_dvd_only (const char *udi,
+ const char *device,
+ const char *mount_point)
+{
+ char *path;
+ gboolean retval;
+
+ path = g_build_path (G_DIR_SEPARATOR_S, mount_point, "video_ts", NULL);
+ retval = g_file_test (path, G_FILE_TEST_IS_DIR);
+ g_free (path);
+
+ /* try the other name, if needed */
+ if (retval == FALSE) {
+ path = g_build_path (G_DIR_SEPARATOR_S, mount_point,
+ "VIDEO_TS", NULL);
+ retval = g_file_test (path, G_FILE_TEST_IS_DIR);
+ g_free (path);
+ }
- return retval;
+ return retval;
}
/* END copied from mate-volume-manager/src/manager.c */
static gboolean
check_dvd_video (DriveButton *self)
{
- GFile *file;
- char *udi, *device_path, *mount_path;
- gboolean result;
- GMount *mount;
+ GFile *file;
+ char *udi, *device_path, *mount_path;
+ gboolean result;
+ GMount *mount;
- if (!self->volume)
- return FALSE;
+ if (!self->volume)
+ return FALSE;
- mount = g_volume_get_mount (self->volume);
- if (!mount)
- return FALSE;
+ mount = g_volume_get_mount (self->volume);
+ if (!mount)
+ return FALSE;
- file = g_mount_get_root (mount);
- g_object_unref (mount);
+ file = g_mount_get_root (mount);
+ g_object_unref (mount);
- if (!file)
- return FALSE;
+ if (!file)
+ return FALSE;
- mount_path = g_file_get_path (file);
+ mount_path = g_file_get_path (file);
- g_object_unref (file);
+ g_object_unref (file);
- device_path = g_volume_get_identifier (self->volume,
- G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
- udi = g_volume_get_identifier (self->volume,
- G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
+ device_path = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ udi = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_HAL_UDI);
- result = gvm_check_dvd_only (udi, device_path, mount_path);
+ result = gvm_check_dvd_only (udi, device_path, mount_path);
- g_free (device_path);
- g_free (udi);
- g_free (mount_path);
+ g_free (device_path);
+ g_free (udi);
+ g_free (mount_path);
- return result;
+ return result;
}
static gboolean
check_audio_cd (DriveButton *self)
{
- GFile *file;
- char *activation_uri;
- GMount *mount;
+ GFile *file;
+ char *activation_uri;
+ GMount *mount;
- if (!self->volume)
- return FALSE;
+ if (!self->volume)
+ return FALSE;
- mount = g_volume_get_mount (self->volume);
- if (!mount)
- return FALSE;
+ mount = g_volume_get_mount (self->volume);
+ if (!mount)
+ return FALSE;
- file = g_mount_get_root (mount);
- g_object_unref (mount);
+ file = g_mount_get_root (mount);
+ g_object_unref (mount);
- if (!file)
- return FALSE;
+ if (!file)
+ return FALSE;
- activation_uri = g_file_get_uri (file);
+ activation_uri = g_file_get_uri (file);
- g_object_unref (file);
+ g_object_unref (file);
- /* we have an audioCD if the activation URI starts by 'cdda://' */
- gboolean result = (strncmp ("cdda://", activation_uri, 7) == 0);
- g_free (activation_uri);
- return result;
+ /* we have an audioCD if the activation URI starts by 'cdda://' */
+ gboolean result = (strncmp ("cdda://", activation_uri, 7) == 0);
+ g_free (activation_uri);
+ return result;
}
static void
-run_command (DriveButton *self, const char *command)
+run_command (DriveButton *self,
+ const char *command)
{
- GFile *file;
- char *mount_path, *device_path;
- GMount *mount;
+ GFile *file;
+ char *mount_path, *device_path;
+ GMount *mount;
- if (!self->volume)
- return;
+ if (!self->volume)
+ return;
- mount = g_volume_get_mount (self->volume);
- if (!mount)
- return;
+ mount = g_volume_get_mount (self->volume);
+ if (!mount)
+ return;
- file = g_mount_get_root (mount);
- g_object_unref (mount);
+ file = g_mount_get_root (mount);
+ g_object_unref (mount);
- g_assert (file);
+ g_assert (file);
- mount_path = g_file_get_path (file);
+ mount_path = g_file_get_path (file);
- g_object_unref (file);
+ g_object_unref (file);
- device_path = g_volume_get_identifier (self->volume,
- G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+ device_path = g_volume_get_identifier (self->volume,
+ G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
- gvm_run_command (device_path, command, mount_path);
+ gvm_run_command (device_path, command, mount_path);
- g_free (mount_path);
- g_free (device_path);
+ g_free (mount_path);
+ g_free (device_path);
}
-static void dummy_async_ready_callback(GObject *source_object, GAsyncResult *res, gpointer user_data) {
- /* do nothing */
+static void dummy_async_ready_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ /* do nothing */
}
static void
-mount_drive (DriveButton *self, GtkWidget *item)
+mount_drive (DriveButton *self,
+ GtkWidget *item)
{
if (self->volume) {
GMountOperation *mount_op = gtk_mount_operation_new (NULL);
- g_volume_mount (self->volume, G_MOUNT_MOUNT_NONE,
- mount_op, NULL, dummy_async_ready_callback, NULL);
+ g_volume_mount (self->volume, G_MOUNT_MOUNT_NONE,
+ mount_op, NULL, dummy_async_ready_callback, NULL);
g_object_unref (mount_op);
} else {
- g_return_if_reached();
+ g_return_if_reached ();
}
}
static void
-unmount_drive (DriveButton *self, GtkWidget *item)
+unmount_drive (DriveButton *self,
+ GtkWidget *item)
{
if (self->volume) {
- GMount *mount;
-
- mount = g_volume_get_mount (self->volume);
- if (mount)
- {
- g_mount_unmount_with_operation (mount, G_MOUNT_UNMOUNT_NONE,
- NULL, NULL, dummy_async_ready_callback, NULL);
- g_object_unref (mount);
- }
+ GMount *mount;
+
+ mount = g_volume_get_mount (self->volume);
+ if (mount) {
+ g_mount_unmount_with_operation (mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, dummy_async_ready_callback, NULL);
+ g_object_unref (mount);
+ }
} else if (self->mount) {
- g_mount_unmount_with_operation (self->mount, G_MOUNT_UNMOUNT_NONE,
- NULL, NULL, dummy_async_ready_callback, NULL);
+ g_mount_unmount_with_operation (self->mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL, dummy_async_ready_callback, NULL);
} else {
- g_return_if_reached();
+ g_return_if_reached ();
}
}
-static void eject_finish (DriveButton *self, GAsyncResult *res,
- gpointer user_data)
+static void eject_finish (DriveButton *self,
+ GAsyncResult *res,
+ gpointer user_data)
{
/* Do nothing. We shouldn't need this according to the GIO
* docs, but the applet crashes without it using glib 2.18.0 */
}
static void
-eject_drive (DriveButton *self, GtkWidget *item)
+eject_drive (DriveButton *self,
+ GtkWidget *item)
{
if (self->volume) {
- g_volume_eject_with_operation (self->volume, G_MOUNT_UNMOUNT_NONE,
- NULL, NULL,
- (GAsyncReadyCallback) eject_finish,
- NULL);
+ g_volume_eject_with_operation (self->volume, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL,
+ (GAsyncReadyCallback) eject_finish,
+ NULL);
} else if (self->mount) {
- g_mount_eject_with_operation (self->mount, G_MOUNT_UNMOUNT_NONE,
- NULL, NULL,
- (GAsyncReadyCallback) eject_finish,
- NULL);
+ g_mount_eject_with_operation (self->mount, G_MOUNT_UNMOUNT_NONE,
+ NULL, NULL,
+ (GAsyncReadyCallback) eject_finish,
+ NULL);
} else {
- g_return_if_reached();
+ g_return_if_reached ();
}
}
static void
-play_autoplay_media (DriveButton *self, const char *dflt)
+play_autoplay_media (DriveButton *self,
+ const char *dflt)
{
- run_command (self, dflt);
+ run_command (self, dflt);
}
static void
-play_dvd (DriveButton *self, GtkWidget *item)
+play_dvd (DriveButton *self,
+ GtkWidget *item)
{
- /* FIXME add an option to set this */
- play_autoplay_media (self, "totem %d");
+ /* FIXME add an option to set this */
+ play_autoplay_media (self, "totem %d");
}
static void
-play_cda (DriveButton *self, GtkWidget *item)
+play_cda (DriveButton *self,
+ GtkWidget *item)
{
- /* FIXME add an option to set this */
- play_autoplay_media (self, "sound-juicer -d %d");
+ /* FIXME add an option to set this */
+ play_autoplay_media (self, "sound-juicer -d %d");
}
static void
@@ -881,24 +903,24 @@ drive_button_ensure_popup (DriveButton *self)
mounted = FALSE;
if (self->volume) {
- GMount *mount = NULL;
+ GMount *mount = NULL;
- display_name = g_volume_get_name (self->volume);
- ejectable = g_volume_can_eject (self->volume);
+ display_name = g_volume_get_name (self->volume);
+ ejectable = g_volume_can_eject (self->volume);
- mount = g_volume_get_mount (self->volume);
- if (mount) {
- mounted = TRUE;
- g_object_unref (mount);
- }
+ mount = g_volume_get_mount (self->volume);
+ if (mount) {
+ mounted = TRUE;
+ g_object_unref (mount);
+ }
} else {
- if (!G_IS_MOUNT(self->volume))
- return;
- else {
- display_name = g_mount_get_name (self->mount);
- ejectable = g_mount_can_eject (self->mount);
- mounted = TRUE;
- }
+ if (!G_IS_MOUNT (self->volume))
+ return;
+ else {
+ display_name = g_mount_get_name (self->mount);
+ ejectable = g_mount_can_eject (self->mount);
+ mounted = TRUE;
+ }
}
self->popup_menu = gtk_menu_new ();
@@ -909,52 +931,52 @@ drive_button_ensure_popup (DriveButton *self)
display_name = tmp;
if (check_dvd_video (self)) {
- item = create_menu_item (self, "media-playback-start",
- _("_Play DVD"), G_CALLBACK (play_dvd),
- TRUE);
+ item = create_menu_item (self, "media-playback-start",
+ _("_Play DVD"), G_CALLBACK (play_dvd),
+ TRUE);
} else if (check_audio_cd (self)) {
- item = create_menu_item (self, "media-playback-start",
- _("_Play CD"), G_CALLBACK (play_cda),
- TRUE);
+ item = create_menu_item (self, "media-playback-start",
+ _("_Play CD"), G_CALLBACK (play_cda),
+ TRUE);
} else {
- label = g_strdup_printf (_("_Open %s"), display_name);
- item = create_menu_item (self, "document-open", label,
- G_CALLBACK (open_drive), mounted);
- g_free (label);
+ label = g_strdup_printf (_("_Open %s"), display_name);
+ item = create_menu_item (self, "document-open", label,
+ G_CALLBACK (open_drive), mounted);
+ g_free (label);
}
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
if (mounted) {
label = g_strdup_printf (_("Un_mount %s"), display_name);
item = create_menu_item (self, NULL, label,
- G_CALLBACK (unmount_drive), TRUE);
+ G_CALLBACK (unmount_drive), TRUE);
g_free (label);
gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
} else {
- label = g_strdup_printf (_("_Mount %s"), display_name);
- item = create_menu_item (self, NULL, label,
- G_CALLBACK (mount_drive), TRUE);
- g_free (label);
- gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
+ label = g_strdup_printf (_("_Mount %s"), display_name);
+ item = create_menu_item (self, NULL, label,
+ G_CALLBACK (mount_drive), TRUE);
+ g_free (label);
+ gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
}
if (ejectable) {
- label = g_strdup_printf (_("_Eject %s"), display_name);
- item = create_menu_item (self, "media-eject", label,
- G_CALLBACK (eject_drive), TRUE);
- g_free (label);
- gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
+ label = g_strdup_printf (_("_Eject %s"), display_name);
+ item = create_menu_item (self, "media-eject", label,
+ G_CALLBACK (eject_drive), TRUE);
+ g_free (label);
+ gtk_container_add (GTK_CONTAINER (self->popup_menu), item);
}
- /*Set up custom theme and transparency support */
- GtkWidget *toplevel = gtk_widget_get_toplevel (self->popup_menu);
- /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
- GdkScreen *screen2 = gtk_widget_get_screen(GTK_WIDGET(toplevel));
- GdkVisual *visual = gdk_screen_get_rgba_visual(screen2);
- gtk_widget_set_visual(GTK_WIDGET(toplevel), visual);
- /*set menu and it's toplevel window to follow panel theme */
- GtkStyleContext *context;
- context = gtk_widget_get_style_context (GTK_WIDGET(toplevel));
- gtk_style_context_add_class(context,"gnome-panel-menu-bar");
- gtk_style_context_add_class(context,"mate-panel-menu-bar");
+ /*Set up custom theme and transparency support */
+ GtkWidget *toplevel = gtk_widget_get_toplevel (self->popup_menu);
+ /* Fix any failures of compiz/other wm's to communicate with gtk for transparency */
+ GdkScreen *screen2 = gtk_widget_get_screen (GTK_WIDGET (toplevel));
+ GdkVisual *visual = gdk_screen_get_rgba_visual (screen2);
+ gtk_widget_set_visual (GTK_WIDGET (toplevel), visual);
+ /*set menu and it's toplevel window to follow panel theme */
+ GtkStyleContext *context;
+ context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
+ gtk_style_context_add_class (context,"gnome-panel-menu-bar");
+ gtk_style_context_add_class (context,"mate-panel-menu-bar");
}
diff --git a/drivemount/drive-button.h b/drivemount/drive-button.h
index 010e65a0..fdab2f16 100644
--- a/drivemount/drive-button.h
+++ b/drivemount/drive-button.h
@@ -59,10 +59,10 @@ GtkWidget *drive_button_new (GVolume *volume);
GtkWidget *drive_button_new_from_mount (GMount *mount);
void drive_button_queue_update (DriveButton *button);
void drive_button_set_size (DriveButton *button,
- int icon_size);
+ int icon_size);
int drive_button_compare (DriveButton *button,
- DriveButton *other_button);
+ DriveButton *other_button);
void drive_button_redraw (gpointer key, gpointer value, gpointer user_data);
diff --git a/drivemount/drive-list.c b/drivemount/drive-list.c
index 97e28573..b1840051 100644
--- a/drivemount/drive-list.c
+++ b/drivemount/drive-list.c
@@ -39,33 +39,18 @@ static void drive_list_dispose (GObject *object);
static void drive_list_add (GtkContainer *container, GtkWidget *child);
static void drive_list_remove (GtkContainer *container, GtkWidget *child);
-static void mount_added (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self);
-static void mount_changed (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self);
-static void mount_removed (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self);
-static void volume_added (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self);
-static void volume_changed (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self);
-static void volume_removed (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self);
-static void add_volume (DriveList *self,
- GVolume *volume);
-static void remove_volume (DriveList *self,
- GVolume *volume);
-static void add_mount (DriveList *self,
- GMount *mount);
-static void remove_mount (DriveList *self,
- GMount *mount);
-static void queue_relayout (DriveList *self);
+static void mount_added (GVolumeMonitor *monitor, GMount *mount, DriveList *self);
+static void mount_changed (GVolumeMonitor *monitor, GMount *mount, DriveList *self);
+static void mount_removed (GVolumeMonitor *monitor, GMount *mount, DriveList *self);
+static void volume_added (GVolumeMonitor *monitor, GVolume *volume, DriveList *self);
+static void volume_changed (GVolumeMonitor *monitor, GVolume *volume, DriveList *self);
+static void volume_removed (GVolumeMonitor *monitor, GVolume *volume, DriveList *self);
+static void add_volume (DriveList *self, GVolume *volume);
+static void remove_volume (DriveList *self, GVolume *volume);
+static void add_mount (DriveList *self, GMount *mount);
+static void remove_mount (DriveList *self, GMount *mount);
+static void queue_relayout (DriveList *self);
+
static void
drive_list_class_init (DriveListClass *class)
{
@@ -91,57 +76,54 @@ drive_list_init (DriveList *self)
self->icon_size = 24;
self->relief = GTK_RELIEF_NORMAL;
- g_signal_connect(self->settings,
- "changed::drivemount-checkmark-color",
- G_CALLBACK (settings_color_changed),
- self);
+ g_signal_connect (self->settings,
+ "changed::drivemount-checkmark-color",
+ G_CALLBACK (settings_color_changed),
+ self);
/* listen for drive connects/disconnects, and add
* currently connected drives. */
- self->count = 0;
- if (!volume_monitor)
- volume_monitor = g_volume_monitor_get ();
+ self->count = 0;
+ if (!volume_monitor)
+ volume_monitor = g_volume_monitor_get ();
g_signal_connect_object (volume_monitor, "mount_added",
- G_CALLBACK (mount_added), self, 0);
+ G_CALLBACK (mount_added), self, 0);
g_signal_connect_object (volume_monitor, "mount_changed",
- G_CALLBACK (mount_changed), self, 0);
+ G_CALLBACK (mount_changed), self, 0);
g_signal_connect_object (volume_monitor, "mount_removed",
- G_CALLBACK (mount_removed), self, 0);
+ G_CALLBACK (mount_removed), self, 0);
g_signal_connect_object (volume_monitor, "volume_added",
- G_CALLBACK (volume_added), self, 0);
+ G_CALLBACK (volume_added), self, 0);
g_signal_connect_object (volume_monitor, "volume_changed",
- G_CALLBACK (volume_changed), self, 0);
+ G_CALLBACK (volume_changed), self, 0);
g_signal_connect_object (volume_monitor, "volume_removed",
- G_CALLBACK (volume_removed), self, 0);
- volumes = g_volume_monitor_get_volumes (volume_monitor);
- for (tmp = volumes; tmp != NULL; tmp = tmp->next)
- {
- GVolume *volume = tmp->data;
- add_volume (self, volume);
- g_object_unref (volume);
- self->count++;
- }
- g_list_free (volumes);
-
- mounts = g_volume_monitor_get_mounts (volume_monitor);
- for (tmp = mounts; tmp != NULL; tmp = tmp->next)
- {
- GMount *mount = tmp->data;
- add_mount (self, mount);
- g_object_unref (mount);
- self->count++;
- }
- self->dummy = drive_button_new (NULL);
- gtk_button_set_relief (GTK_BUTTON (self->dummy), self->relief);
- drive_button_set_size (DRIVE_BUTTON (self->dummy), self->icon_size);
-
- if (self->count == 0)
- {
- gtk_container_add (GTK_CONTAINER (self), self->dummy);
- queue_relayout (self);
- drive_button_queue_update (DRIVE_BUTTON (self->dummy));
- }
+ G_CALLBACK (volume_removed), self, 0);
+ volumes = g_volume_monitor_get_volumes (volume_monitor);
+ for (tmp = volumes; tmp != NULL; tmp = tmp->next) {
+ GVolume *volume = tmp->data;
+ add_volume (self, volume);
+ g_object_unref (volume);
+ self->count++;
+ }
+ g_list_free (volumes);
+
+ mounts = g_volume_monitor_get_mounts (volume_monitor);
+ for (tmp = mounts; tmp != NULL; tmp = tmp->next) {
+ GMount *mount = tmp->data;
+ add_mount (self, mount);
+ g_object_unref (mount);
+ self->count++;
+ }
+ self->dummy = drive_button_new (NULL);
+ gtk_button_set_relief (GTK_BUTTON (self->dummy), self->relief);
+ drive_button_set_size (DRIVE_BUTTON (self->dummy), self->icon_size);
+
+ if (self->count == 0) {
+ gtk_container_add (GTK_CONTAINER (self), self->dummy);
+ queue_relayout (self);
+ drive_button_queue_update (DRIVE_BUTTON (self->dummy));
+ }
g_list_free (mounts);
}
@@ -161,7 +143,7 @@ drive_list_finalize (GObject *object)
g_object_unref (self->settings);
if (G_OBJECT_CLASS (drive_list_parent_class)->finalize)
- (* G_OBJECT_CLASS (drive_list_parent_class)->finalize) (object);
+ (* G_OBJECT_CLASS (drive_list_parent_class)->finalize) (object);
}
static void
@@ -170,28 +152,29 @@ drive_list_dispose (GObject *object)
DriveList *self = DRIVE_LIST (object);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (mount_added), self);
+ G_CALLBACK (mount_added), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (mount_changed), self);
+ G_CALLBACK (mount_changed), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (mount_removed), self);
+ G_CALLBACK (mount_removed), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (volume_added), self);
+ G_CALLBACK (volume_added), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (volume_changed), self);
+ G_CALLBACK (volume_changed), self);
g_signal_handlers_disconnect_by_func (volume_monitor,
- G_CALLBACK (volume_removed), self);
+ G_CALLBACK (volume_removed), self);
if (self->layout_tag)
- g_source_remove (self->layout_tag);
+ g_source_remove (self->layout_tag);
self->layout_tag = 0;
if (G_OBJECT_CLASS (drive_list_parent_class)->dispose)
- (* G_OBJECT_CLASS (drive_list_parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (drive_list_parent_class)->dispose) (object);
}
static void
-drive_list_add (GtkContainer *container, GtkWidget *child)
+drive_list_add (GtkContainer *container,
+ GtkWidget *child)
{
DriveList *self;
DriveButton *button;
@@ -200,19 +183,19 @@ drive_list_add (GtkContainer *container, GtkWidget *child)
g_return_if_fail (DRIVE_IS_BUTTON (child));
if (GTK_CONTAINER_CLASS (drive_list_parent_class)->add)
- (* GTK_CONTAINER_CLASS (drive_list_parent_class)->add) (container,
- child);
+ (* GTK_CONTAINER_CLASS (drive_list_parent_class)->add) (container, child);
self = DRIVE_LIST (container);
button = DRIVE_BUTTON (child);
if (button->volume)
- g_hash_table_insert (self->volumes, button->volume, button);
+ g_hash_table_insert (self->volumes, button->volume, button);
else
- g_hash_table_insert (self->mounts, button->mount, button);
+ g_hash_table_insert (self->mounts, button->mount, button);
}
static void
-drive_list_remove (GtkContainer *container, GtkWidget *child)
+drive_list_remove (GtkContainer *container,
+ GtkWidget *child)
{
DriveList *self;
DriveButton *button;
@@ -223,177 +206,173 @@ drive_list_remove (GtkContainer *container, GtkWidget *child)
self = DRIVE_LIST (container);
button = DRIVE_BUTTON (child);
if (button->volume)
- g_hash_table_remove (self->volumes, button->volume);
+ g_hash_table_remove (self->volumes, button->volume);
else
- g_hash_table_remove (self->mounts, button->mount);
+ g_hash_table_remove (self->mounts, button->mount);
if (GTK_CONTAINER_CLASS (drive_list_parent_class)->remove)
- (* GTK_CONTAINER_CLASS (drive_list_parent_class)->remove) (container,
- child);
+ (* GTK_CONTAINER_CLASS (drive_list_parent_class)->remove) (container, child);
}
static void
-list_buttons (gpointer key, gpointer value, gpointer user_data)
+list_buttons (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
GtkWidget *button = value;
GList **sorted_buttons = user_data;
*sorted_buttons = g_list_insert_sorted (*sorted_buttons, button,
- (GCompareFunc)drive_button_compare);
+ (GCompareFunc)drive_button_compare);
}
static gboolean
relayout_buttons (gpointer data)
{
- DriveList *self = DRIVE_LIST (data);
- GList *sorted_buttons = NULL, *tmp;
- int i = 0;
-
-
- self->layout_tag = 0;
- if ( self->count > 0 )
- {
- g_hash_table_foreach (self->volumes, list_buttons, &sorted_buttons);
- g_hash_table_foreach (self->mounts, list_buttons, &sorted_buttons);
-
- /* position buttons in the table according to their sorted order */
- for (tmp = sorted_buttons, i = 0; tmp != NULL; tmp = tmp->next, i++)
- {
- GtkWidget *button = tmp->data;
-
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
- gtk_container_child_set (GTK_CONTAINER (self), button,
- "left-attach", i + 1, "top-attach", 0,
- "width", 1, "height", 1,
- NULL);
- }
- else
- {
- gtk_container_child_set (GTK_CONTAINER (self), button,
- "left-attach", 0, "top-attach", i + 1,
- "width", 1, "height", 1,
- NULL);
- }
- }
- }
- else
- {
- gtk_widget_show (self->dummy);
- if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- gtk_container_child_set (GTK_CONTAINER (self), self->dummy,
- "left-attach", i + 1, "top-attach", 0,
- "width", 1, "height", 1,
- NULL);
- }
- else
- {
- gtk_container_child_set (GTK_CONTAINER (self), self->dummy,
- "left-attach", 0, "top-attach", i + 1,
- "width", 1, "height", 1,
- NULL);
- }
- }
- return FALSE;
+ DriveList *self = DRIVE_LIST (data);
+ GList *sorted_buttons = NULL, *tmp;
+ int i = 0;
+
+ self->layout_tag = 0;
+ if ( self->count > 0 ) {
+ g_hash_table_foreach (self->volumes, list_buttons, &sorted_buttons);
+ g_hash_table_foreach (self->mounts, list_buttons, &sorted_buttons);
+
+ /* position buttons in the table according to their sorted order */
+ for (tmp = sorted_buttons, i = 0; tmp != NULL; tmp = tmp->next, i++) {
+ GtkWidget *button = tmp->data;
+
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ gtk_container_child_set (GTK_CONTAINER (self), button,
+ "left-attach", i + 1, "top-attach", 0,
+ "width", 1, "height", 1,
+ NULL);
+ }
+ else {
+ gtk_container_child_set (GTK_CONTAINER (self), button,
+ "left-attach", 0, "top-attach", i + 1,
+ "width", 1, "height", 1,
+ NULL);
+ }
+ }
+ }
+ else {
+ gtk_widget_show (self->dummy);
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ gtk_container_child_set (GTK_CONTAINER (self), self->dummy,
+ "left-attach", i + 1, "top-attach", 0,
+ "width", 1, "height", 1,
+ NULL);
+ }
+ else {
+ gtk_container_child_set (GTK_CONTAINER (self), self->dummy,
+ "left-attach", 0, "top-attach", i + 1,
+ "width", 1, "height", 1,
+ NULL);
+ }
+ }
+ return FALSE;
}
static void
queue_relayout (DriveList *self)
{
if (!self->layout_tag) {
- self->layout_tag = g_idle_add (relayout_buttons, self);
+ self->layout_tag = g_idle_add (relayout_buttons, self);
}
}
static void
mount_added (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self)
+ GMount *mount,
+ DriveList *self)
{
add_mount (self, mount);
- self->count++;
- if (self->count == 1)
- gtk_container_remove (GTK_CONTAINER (self), g_object_ref(self->dummy));
+ self->count++;
+ if (self->count == 1)
+ gtk_container_remove (GTK_CONTAINER (self), g_object_ref (self->dummy));
+
mount_changed (monitor, mount, self);
}
static void
mount_changed (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self)
+ GMount *mount,
+ DriveList *self)
{
GVolume *volume;
DriveButton *button = NULL;;
volume = g_mount_get_volume (mount);
if (volume) {
- button = g_hash_table_lookup (self->volumes, volume);
- g_object_unref (volume);
+ button = g_hash_table_lookup (self->volumes, volume);
+ g_object_unref (volume);
} else {
- button = g_hash_table_lookup (self->mounts, mount);
+ button = g_hash_table_lookup (self->mounts, mount);
}
if (button)
- drive_button_queue_update (button);
+ drive_button_queue_update (button);
}
static void
mount_removed (GVolumeMonitor *monitor,
- GMount *mount,
- DriveList *self)
+ GMount *mount,
+ DriveList *self)
{
remove_mount (self, mount);
mount_changed (monitor, mount, self);
- self->count--;
- if (self->count == 0) {
- gtk_container_add (GTK_CONTAINER (self), self->dummy);
- queue_relayout(self);
- }
+ self->count--;
+ if (self->count == 0) {
+ gtk_container_add (GTK_CONTAINER (self), self->dummy);
+ queue_relayout (self);
+ }
}
static void
volume_added (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self)
+ GVolume *volume,
+ DriveList *self)
{
add_volume (self, volume);
- self->count++;
- if (self->count == 1)
- gtk_container_remove (GTK_CONTAINER (self), g_object_ref(self->dummy));
+ self->count++;
+ if (self->count == 1)
+ gtk_container_remove (GTK_CONTAINER (self), g_object_ref (self->dummy));
}
static void
volume_changed (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self)
+ GVolume *volume,
+ DriveList *self)
{
DriveButton *button = NULL;;
button = g_hash_table_lookup (self->volumes, volume);
if (button)
- drive_button_queue_update (button);
+ drive_button_queue_update (button);
}
static void
volume_removed (GVolumeMonitor *monitor,
- GVolume *volume,
- DriveList *self)
+ GVolume *volume,
+ DriveList *self)
{
remove_volume (self, volume);
- self->count--;
- if (self->count == 0) {
- gtk_container_add (GTK_CONTAINER (self), self->dummy);
- queue_relayout(self);
- }
+ self->count--;
+ if (self->count == 0) {
+ gtk_container_add (GTK_CONTAINER (self), self->dummy);
+ queue_relayout (self);
+ }
}
static void
-add_volume (DriveList *self, GVolume *volume)
+add_volume (DriveList *self,
+ GVolume *volume)
{
GtkWidget *button;
/* if the volume has already been added, return */
if (g_hash_table_lookup (self->volumes, volume) != NULL)
- return;
+ return;
button = drive_button_new (volume);
gtk_button_set_relief (GTK_BUTTON (button), self->relief);
@@ -404,20 +383,22 @@ add_volume (DriveList *self, GVolume *volume)
}
static void
-remove_volume (DriveList *self, GVolume *volume)
+remove_volume (DriveList *self,
+ GVolume *volume)
{
GtkWidget *button;
/* if the volume has already been added, return */
button = g_hash_table_lookup (self->volumes, volume);
if (button) {
- gtk_container_remove (GTK_CONTAINER (self), button);
- queue_relayout (self);
+ gtk_container_remove (GTK_CONTAINER (self), button);
+ queue_relayout (self);
}
}
static void
-add_mount (DriveList *self, GMount *mount)
+add_mount (DriveList *self,
+ GMount *mount)
{
GtkWidget *button;
GVolume *volume;
@@ -430,13 +411,13 @@ add_mount (DriveList *self, GMount *mount)
/* ignore mounts attached to a volume */
volume = g_mount_get_volume (mount);
if (volume) {
- g_object_unref (volume);
- return;
+ g_object_unref (volume);
+ return;
}
/* if the mount has already been added, return */
if (g_hash_table_lookup (self->mounts, mount) != NULL)
- return;
+ return;
button = drive_button_new_from_mount (mount);
gtk_button_set_relief (GTK_BUTTON (button), self->relief);
@@ -447,32 +428,35 @@ add_mount (DriveList *self, GMount *mount)
}
static void
-remove_mount (DriveList *self, GMount *mount)
+remove_mount (DriveList *self,
+ GMount *mount)
{
GtkWidget *button;
/* if the mount has already been added, return */
button = g_hash_table_lookup (self->mounts, mount);
if (button) {
- gtk_container_remove (GTK_CONTAINER (self), button);
- queue_relayout (self);
+ gtk_container_remove (GTK_CONTAINER (self), button);
+ queue_relayout (self);
}
}
void
-drive_list_set_orientation (DriveList *self,
- GtkOrientation orientation)
+drive_list_set_orientation (DriveList *self,
+ GtkOrientation orientation)
{
g_return_if_fail (DRIVE_IS_LIST (self));
if (orientation != self->orientation) {
- self->orientation = orientation;
- queue_relayout (self);
+ self->orientation = orientation;
+ queue_relayout (self);
}
}
static void
-set_icon_size (gpointer key, gpointer value, gpointer user_data)
+set_icon_size (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
DriveButton *button = value;
DriveList *self = user_data;
@@ -482,14 +466,15 @@ set_icon_size (gpointer key, gpointer value, gpointer user_data)
void
-drive_list_set_panel_size (DriveList *self, int panel_size)
+drive_list_set_panel_size (DriveList *self,
+ int panel_size)
{
g_return_if_fail (DRIVE_IS_LIST (self));
if (self->icon_size != panel_size) {
- self->icon_size = panel_size;
- g_hash_table_foreach (self->volumes, set_icon_size, self);
- g_hash_table_foreach (self->mounts, set_icon_size, self);
+ self->icon_size = panel_size;
+ g_hash_table_foreach (self->volumes, set_icon_size, self);
+ g_hash_table_foreach (self->mounts, set_icon_size, self);
}
}
@@ -501,14 +486,18 @@ drive_list_redraw (DriveList *self)
}
void
-settings_color_changed (GSettings *settings, gchar *key, DriveList *drive_list)
+settings_color_changed (GSettings *settings,
+ gchar *key,
+ DriveList *drive_list)
{
g_return_if_fail (DRIVE_IS_LIST (drive_list));
drive_list_redraw (drive_list);
}
static void
-set_button_relief (gpointer key, gpointer value, gpointer user_data)
+set_button_relief (gpointer key,
+ gpointer value,
+ gpointer user_data)
{
GtkButton *button = value;
DriveList *self = user_data;
@@ -517,7 +506,8 @@ set_button_relief (gpointer key, gpointer value, gpointer user_data)
}
void
-drive_list_set_transparent (DriveList *self, gboolean transparent)
+drive_list_set_transparent (DriveList *self,
+ gboolean transparent)
{
GtkReliefStyle relief;
diff --git a/drivemount/drive-list.h b/drivemount/drive-list.h
index 96eb189a..e2da7333 100644
--- a/drivemount/drive-list.h
+++ b/drivemount/drive-list.h
@@ -62,11 +62,11 @@ struct _DriveListClass
GType drive_list_get_type (void);
GtkWidget *drive_list_new (void);
void drive_list_set_orientation (DriveList *list,
- GtkOrientation orientation);
+ GtkOrientation orientation);
void drive_list_set_panel_size (DriveList *list,
- int panel_size);
+ int panel_size);
void drive_list_set_transparent (DriveList *self,
- gboolean transparent);
+ gboolean transparent);
void drive_list_redraw (DriveList *self);
void settings_color_changed (GSettings *settings, gchar *key, DriveList *drive_list);
diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c
index 450bce32..342ca623 100644
--- a/drivemount/drivemount.c
+++ b/drivemount/drivemount.c
@@ -36,78 +36,76 @@ static const char drivemount_iid[] = "DriveMountApplet";
static const char factory_iid[] = "DriveMountAppletFactory";
static void
-change_orient (MatePanelApplet *applet, MatePanelAppletOrient o, DriveList *drive_list)
+change_orient (MatePanelApplet *applet,
+ MatePanelAppletOrient o,
+ DriveList *drive_list)
{
GtkOrientation orientation;
switch (o) {
- case MATE_PANEL_APPLET_ORIENT_LEFT:
- case MATE_PANEL_APPLET_ORIENT_RIGHT:
- orientation = GTK_ORIENTATION_VERTICAL;
- break;
- case MATE_PANEL_APPLET_ORIENT_UP:
- case MATE_PANEL_APPLET_ORIENT_DOWN:
- default:
- orientation = GTK_ORIENTATION_HORIZONTAL;
- break;
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
+ orientation = GTK_ORIENTATION_VERTICAL;
+ break;
+ case MATE_PANEL_APPLET_ORIENT_UP:
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
+ default:
+ orientation = GTK_ORIENTATION_HORIZONTAL;
}
drive_list_set_orientation (drive_list, orientation);
}
static void
-size_allocate (MatePanelApplet *applet,
- GdkRectangle *allocation,
- DriveList *drive_list)
+size_allocate (MatePanelApplet *applet,
+ GdkRectangle *allocation,
+ DriveList *drive_list)
{
int size;
switch (mate_panel_applet_get_orient (applet)) {
- case MATE_PANEL_APPLET_ORIENT_LEFT:
- case MATE_PANEL_APPLET_ORIENT_RIGHT:
- size = allocation->width;
- break;
- case MATE_PANEL_APPLET_ORIENT_UP:
- case MATE_PANEL_APPLET_ORIENT_DOWN:
- default:
- size = allocation->height;
- break;
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
+ size = allocation->width;
+ break;
+ case MATE_PANEL_APPLET_ORIENT_UP:
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
+ default:
+ size = allocation->height;
}
drive_list_set_panel_size (drive_list, size);
}
static void
change_background (MatePanelApplet *applet,
- MatePanelAppletBackgroundType type,
- GdkColor *colour,
- cairo_pattern_t *pattern,
- DriveList *drivelist)
+ MatePanelAppletBackgroundType type,
+ GdkColor *colour,
+ cairo_pattern_t *pattern,
+ DriveList *drivelist)
{
switch (type) {
- case PANEL_NO_BACKGROUND:
- drive_list_set_transparent (drivelist, FALSE);
- break;
-
- case PANEL_COLOR_BACKGROUND:
- case PANEL_PIXMAP_BACKGROUND:
- drive_list_set_transparent (drivelist, TRUE);
- break;
+ case PANEL_NO_BACKGROUND:
+ drive_list_set_transparent (drivelist, FALSE);
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ case PANEL_PIXMAP_BACKGROUND:
+ drive_list_set_transparent (drivelist, TRUE);
}
}
static void
display_about_dialog (GtkAction *action,
- DriveList *drive_list)
+ DriveList *drive_list)
{
const gchar *authors[] = {
- "James Henstridge <[email protected]>",
- NULL
+ "James Henstridge <[email protected]>",
+ NULL
};
const gchar *documenters[] = {
- "Dan Mueth <[email protected]>",
- "John Fleck <[email protected]>",
- N_("MATE Documentation Team"),
- NULL
+ "Dan Mueth <[email protected]>",
+ "John Fleck <[email protected]>",
+ N_("MATE Documentation Team"),
+ NULL
};
#ifdef ENABLE_NLS
@@ -117,21 +115,21 @@ display_about_dialog (GtkAction *action,
#endif
gtk_show_about_dialog (NULL,
- "title", _("About Disk Mounter"),
- "version", VERSION,
- "copyright", _("Copyright \xC2\xA9 2004 Canonical Ltd\n"
- "Copyright \xc2\xa9 2012-2020 MATE developers"),
- "comments", _("Applet for mounting and unmounting block volumes."),
- "authors", authors,
- "documenters", documenters,
- "translator-credits", _("translator-credits"),
- "logo_icon_name", "media-floppy",
- NULL);
+ "title", _("About Disk Mounter"),
+ "version", VERSION,
+ "copyright", _("Copyright \xC2\xA9 2004 Canonical Ltd\n"
+ "Copyright \xc2\xa9 2012-2020 MATE developers"),
+ "comments", _("Applet for mounting and unmounting block volumes."),
+ "authors", authors,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "logo_icon_name", "media-floppy",
+ NULL);
}
static void
display_help (GtkAction *action,
- DriveList *drive_list)
+ DriveList *drive_list)
{
GdkScreen *screen;
GError *error = NULL;
@@ -139,25 +137,25 @@ display_help (GtkAction *action,
screen = gtk_widget_get_screen (GTK_WIDGET (drive_list));
gtk_show_uri_on_window (NULL,
- "help:mate-drivemount",
+ "help:mate-drivemount",
gtk_get_current_event_time (),
&error);
if (error) {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("There was an error displaying help: %s"),
- error->message);
- g_signal_connect (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), NULL);
- gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- gtk_window_set_screen (GTK_WINDOW (dialog), screen);
- gtk_widget_show (dialog);
- g_error_free (error);
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("There was an error displaying help: %s"),
+ error->message);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+ gtk_widget_show (dialog);
+ g_error_free (error);
}
}
@@ -172,8 +170,8 @@ static const GtkActionEntry applet_menu_actions[] = {
static gboolean
applet_factory (MatePanelApplet *applet,
- const char *iid,
- gpointer user_data)
+ const char *iid,
+ gpointer user_data)
{
gboolean ret = FALSE;
GtkWidget *drive_list;
@@ -181,52 +179,53 @@ applet_factory (MatePanelApplet *applet,
GtkActionGroup *action_group;
if (!strcmp (iid, drivemount_iid)) {
- g_set_application_name (_("Disk Mounter"));
+ g_set_application_name (_("Disk Mounter"));
- gtk_window_set_default_icon_name ("media-floppy");
+ gtk_window_set_default_icon_name ("media-floppy");
- mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
- mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
+ mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+ mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
- drive_list = drive_list_new ();
+ drive_list = drive_list_new ();
- gtk_container_add (GTK_CONTAINER (applet), drive_list);
+ gtk_container_add (GTK_CONTAINER (applet), drive_list);
- g_signal_connect_object (applet, "change_orient",
- G_CALLBACK (change_orient), drive_list, 0);
- g_signal_connect_object (applet, "size_allocate",
- G_CALLBACK (size_allocate), drive_list, 0);
- g_signal_connect (applet, "change_background",
- G_CALLBACK (change_background), drive_list);
+ g_signal_connect_object (applet, "change_orient",
+ G_CALLBACK (change_orient), drive_list, 0);
+ g_signal_connect_object (applet, "size_allocate",
+ G_CALLBACK (size_allocate), drive_list, 0);
+ g_signal_connect (applet, "change_background",
+ G_CALLBACK (change_background), drive_list);
- /* set initial state */
- change_orient (applet,
- mate_panel_applet_get_orient (applet),
- DRIVE_LIST (drive_list));
+ /* set initial state */
+ change_orient (applet,
+ mate_panel_applet_get_orient (applet),
+ DRIVE_LIST (drive_list));
- action_group = gtk_action_group_new ("DriveMount Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- applet_menu_actions,
- G_N_ELEMENTS (applet_menu_actions),
- drive_list);
- mate_panel_applet_setup_menu_from_resource (applet,
- DRIVEMOUNT_RESOURCE_PATH "drivemount-applet-menu.xml",
- action_group);
- g_object_unref (action_group);
+ action_group = gtk_action_group_new ("DriveMount Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ applet_menu_actions,
+ G_N_ELEMENTS (applet_menu_actions),
+ drive_list);
+ mate_panel_applet_setup_menu_from_resource (applet,
+ DRIVEMOUNT_RESOURCE_PATH "drivemount-applet-menu.xml",
+ action_group);
+ g_object_unref (action_group);
- ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
- atk_object_set_name (ao, _("Disk Mounter"));
+ ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
+ atk_object_set_name (ao, _("Disk Mounter"));
- gtk_widget_show_all (GTK_WIDGET (applet));
+ gtk_widget_show_all (GTK_WIDGET (applet));
- ret = TRUE;
+ ret = TRUE;
}
return ret;
}
MATE_PANEL_APPLET_OUT_PROCESS_FACTORY (factory_iid,
- PANEL_TYPE_APPLET,
- "Drive-Mount-Applet",
- applet_factory, NULL)
+ PANEL_TYPE_APPLET,
+ "Drive-Mount-Applet",
+ applet_factory, NULL)
+