summaryrefslogtreecommitdiff
path: root/mate-volume-control/applet-main.c
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-02-07 12:17:22 -0500
committerlukefromdc <[email protected]>2019-02-26 01:48:56 -0500
commit5fd1ba21e41281195e39366061e0d9d0535df014 (patch)
tree98de9e06e4bec8dbc593dc545545f8e4ba546b20 /mate-volume-control/applet-main.c
parent6aefae09c11f23cfc3847a07f191e2d258888782 (diff)
downloadmate-media-5fd1ba21e41281195e39366061e0d9d0535df014.tar.bz2
mate-media-5fd1ba21e41281195e39366061e0d9d0535df014.tar.xz
Convert GtkStatusIcon to real applet
Diffstat (limited to 'mate-volume-control/applet-main.c')
-rw-r--r--mate-volume-control/applet-main.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/mate-volume-control/applet-main.c b/mate-volume-control/applet-main.c
index 23bef45..776f823 100644
--- a/mate-volume-control/applet-main.c
+++ b/mate-volume-control/applet-main.c
@@ -29,60 +29,35 @@
#include <libintl.h>
#include <gio/gio.h>
#include <libmatemixer/matemixer.h>
+#include <mate-panel-applet.h>
#include "gvc-applet.h"
-static gboolean show_version = FALSE;
-static gboolean debug = FALSE;
-
-int
-main (int argc, char **argv)
+static gboolean
+applet_main (MatePanelApplet* applet_widget)
{
GError *error = NULL;
GvcApplet *applet;
GApplication *app = NULL;
- GOptionEntry entries[] = {
- { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL },
- { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug"), NULL },
- { NULL }
- };
bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- gtk_init_with_args (&argc, &argv,
- _(" — MATE Volume Control Applet"),
- entries, GETTEXT_PACKAGE,
- &error);
-
- if (error != NULL) {
- g_warning ("%s", error->message);
- g_error_free (error);
- return 1;
- }
- if (show_version == TRUE) {
- g_print ("%s %s\n", argv[0], VERSION);
- return 0;
- }
- if (debug == TRUE) {
- g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
- }
-
app = g_application_new (GVC_APPLET_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
if (!g_application_register (app, NULL, &error)) {
g_warning ("%s", error->message);
g_error_free (error);
- return 1;
+ return FALSE;
}
if (g_application_get_is_remote (app)) {
g_warning ("Applet is already running, exiting");
- return 0;
+ return TRUE;
}
if (mate_mixer_init () == FALSE) {
g_warning ("libmatemixer initialization failed, exiting");
- return 1;
+ return FALSE;
}
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
@@ -90,11 +65,29 @@ main (int argc, char **argv)
applet = gvc_applet_new ();
+ gvc_applet_fill (applet, applet_widget);
gvc_applet_start (applet);
- gtk_main ();
- g_object_unref (applet);
g_object_unref (app);
- return 0;
+ return TRUE;
}
+
+/* this function, called by mate-panel, will create the applet */
+static gboolean
+applet_factory (MatePanelApplet* applet, const char* iid, gpointer data)
+{
+ gboolean retval = FALSE;
+
+ if (!g_strcmp0 (iid, "GvcApplet"))
+ retval = applet_main (applet);
+
+ return retval;
+}
+
+/* needed by mate-panel applet library */
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY("GvcAppletFactory",
+ PANEL_TYPE_APPLET,
+ "Volume Control applet",
+ applet_factory,
+ NULL)