@Iguleder - I hacked in a test for using literocks to manage trayapplets. To allow them to be pinboard_save()d, it eventually needs to be a included in the current_pinboard as a GList of something like:
btw... I also removed some more old pinboard style cruft.
Code: Select all
--- literocks-master/ROX-Filer/src/pinboard.c 2012-11-17 06:30:27.000000000 +0800
+++ literocks-applets/ROX-Filer/src/pinboard.c 2014-01-20 13:36:06.398520740 +0800
@@ -166,7 +166,6 @@ static gboolean scroll_event(GtkWidget *
static gint icon_motion_notify(GtkWidget *widget,
GdkEventMotion *event,
PinIcon *pi);
-static const char *pin_from_file(gchar *line);
static void snap_to_grid(int *x, int *y);
static void offset_from_centre(PinIcon *pi, int *x, int *y);
static gboolean drag_motion(GtkWidget *widget,
@@ -333,13 +332,6 @@ void pinboard_activate(const gchar *name
current_pinboard->backdrop,
current_pinboard->backdrop_style);
}
- else
- {
- parse_file(path, pin_from_file);
- info_message(_("Your old pinboard file has been "
- "converted to the new XML format."));
- pinboard_save();
- }
g_free(path);
}
else
@@ -1445,6 +1437,62 @@ static void backdrop_from_xml(xmlNode *n
current_pinboard->backdrop_style = BACKDROP_TILE;
}
+static void leftclick(GtkStatusIcon *si, gpointer s){
+ g_spawn_command_line_async(s,NULL);
+}
+
+static void rightclick(GtkStatusIcon *si, guint b,guint a_t, gpointer s){
+ g_spawn_command_line_async(s,NULL);
+}
+
+/** refreshes the status icon image from file if it changes */
+static void refresh(GFileMonitor *monitor, GFile *file, GFile *to_file, GFileMonitorEvent event, gpointer si){
+ gtk_status_icon_set_from_file(si,g_file_get_path(file));
+}
+
+/** gets a new mouse over tooltip from file if it changes */
+static void updatetooltip(GFileMonitor *monitor, GFile *file, GFile *to_file, GFileMonitorEvent event, gpointer si){
+ gtk_status_icon_set_tooltip_markup(si, g_mapped_file_get_contents(g_mapped_file_new(g_file_get_path(file), FALSE, NULL)));
+}
+
+gchar *applets; //hack to prevent having to free/reload every pinboard reload
+static void applet_from_xml(xmlNode *node)
+{
+ gchar *applet,*tt,*lc,*rc,*app;
+ GtkStatusIcon *si;
+
+ applet = xmlNodeGetContent(node);
+ g_return_if_fail(applet != NULL);
+ g_return_if_fail(g_strstr(applets,applet) != NULL);
+ applets = g_strconcat(applets,applet,NULL);
+ if (g_file_test(applet, G_FILE_TEST_EXISTS)){
+ si = gtk_status_icon_new_from_file(applet);
+ g_signal_connect(g_file_monitor_file(g_file_new_for_path(applet),
+ G_FILE_MONITOR_NONE, FALSE, NULL), "changed",
+ G_CALLBACK(refresh),(gpointer) si);
+ }else return;
+
+
+ tt = xmlGetProp(node, "tt");
+ if (tt && g_file_test(tt, G_FILE_TEST_EXISTS)) {
+ gtk_status_icon_set_tooltip_markup(si,
+ g_mapped_file_get_contents(g_mapped_file_new(tt, FALSE, NULL)));
+ g_signal_connect(g_file_monitor_file(g_file_new_for_path(tt),
+ G_FILE_MONITOR_NONE, FALSE, NULL), "changed",
+ G_CALLBACK(updatetooltip),(gpointer) si);
+ } else if (tt) gtk_status_icon_set_tooltip_markup(si, tt);
+
+ lc = xmlGetProp(node, "lc");
+ if (lc) g_signal_connect(G_OBJECT(si), "activate", G_CALLBACK(leftclick),(gpointer) lc);
+
+ rc= xmlGetProp(node, "rc");
+ if (rc) g_signal_connect(G_OBJECT(si), "popup-menu", G_CALLBACK(rightclick), (gpointer) rc);
+
+ app = xmlGetProp(node, "app");
+ if (app) g_spawn_command_line_async(app,NULL);
+
+}
+
/* Create one pinboard icon for each icon in the doc */
static void pinboard_load_from_xml(xmlDocPtr doc)
{
@@ -1464,6 +1512,11 @@ static void pinboard_load_from_xml(xmlDo
backdrop_from_xml(node);
continue;
}
+ if (strcmp(node->name, "applet") == 0)
+ {
+ applet_from_xml(node);
+ continue;
+ }
if (strcmp(node->name, "icon") != 0)
continue;
@@ -1506,43 +1559,6 @@ static void pinboard_load_from_xml(xmlDo
}
}
-/* Called for each line in the pinboard file while loading a new board.
- * Only used for old-format files when converting to XML.
- */
-static const char *pin_from_file(gchar *line)
-{
- gchar *leaf = NULL;
- int x, y, n;
-
- if (*line == '<')
- {
- gchar *end;
-
- end = strchr(line + 1, '>');
- if (!end)
- return _("Missing '>' in icon label");
-
- leaf = g_strndup(line + 1, end - line - 1);
-
- line = end + 1;
-
- while (g_ascii_isspace(*line))
- line++;
- if (*line != ',')
- return _("Missing ',' after icon label");
- line++;
- }
-
- if (sscanf(line, " %d , %d , %n", &x, &y, &n) < 2)
- return NULL; /* Ignore format errors */
-
- pinboard_pin(line + n, leaf, x, y, NULL);
-
- g_free(leaf);
-
- return NULL;
-}
-
/* Write the current state of the pinboard to the current pinboard file */
static void pinboard_save(void)
{
This can replace all tray applets using minimal resources similar to my simple icon tray app, but using rox as the controlling process