summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-01-19 00:44:17 +0100
committerJavier <dev.git@javispedro.com>2015-01-19 00:44:17 +0100
commit8069ebf9a157ce0952fd9f3ed6a4edcdce071911 (patch)
tree50249ee1554cc8353c427a2c7f336e7d710754be
parentcd89c60570d17cad28928f3495eded7af2b45431 (diff)
downloadmdock-8069ebf9a157ce0952fd9f3ed6a4edcdce071911.tar.gz
mdock-8069ebf9a157ce0952fd9f3ed6a4edcdce071911.zip
fixing enums
-rw-r--r--libmdock/Makefile.am14
-rw-r--r--libmdock/matcher.c34
-rw-r--r--libmdock/matcher.h2
-rw-r--r--libmdock/mdock-enums.c6
-rw-r--r--libmdock/mdock-enums.c.template38
-rw-r--r--libmdock/mdock-enums.h25
-rw-r--r--libmdock/mdock-enums.h.template24
-rw-r--r--libmdock/mdock-item.h6
-rw-r--r--libmdock/mdock-widget.c5
9 files changed, 114 insertions, 40 deletions
diff --git a/libmdock/Makefile.am b/libmdock/Makefile.am
index 7c5514e..dedf339 100644
--- a/libmdock/Makefile.am
+++ b/libmdock/Makefile.am
@@ -5,10 +5,16 @@ libmdock_la_LIBADD = $(GTK_LIBS) $(GIO_LIBS) $(WNCK_LIBS) $(GTOP_LIBS)
gsettings_SCHEMAS = com.javispedro.mdock.widget.gschema.xml
-include_HEADERS = mdock-widget.h mdock-item.h mdock-enums.h
-CLEANFILES = mdock-enums.c
+include_HEADERS = mdock-widget.h mdock-item.h
+CLEANFILES = mdock-enums.c mdock-enums.h
-mdock-enums.c: mdock-enums.h
- glib-mkenums $< > $@
+EXTRA_DIST = mdock-enums.h.template mdock-enums.c.template
+BUILT_SOURCES = mdock-enums.h mdock-enums.c
+
+mdock-enums.c: mdock-enums.c.template $(include_HEADERS)
+ glib-mkenums --template $< $(include_HEADERS) > $@
+
+mdock-enums.h: mdock-enums.h.template $(include_HEADERS)
+ glib-mkenums --template $< $(include_HEADERS) > $@
@GSETTINGS_RULES@
diff --git a/libmdock/matcher.c b/libmdock/matcher.c
index 25e2b2f..5c1bd8b 100644
--- a/libmdock/matcher.c
+++ b/libmdock/matcher.c
@@ -18,6 +18,7 @@
*/
#include <ftw.h>
+#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gio/gio.h>
@@ -107,6 +108,18 @@ static void add_desktop_item_by_wmclass(const gchar *wmclass, GDesktopAppInfo *i
elist->list = g_slist_append(elist->list, item);
}
+static gchar *resolve_path(const gchar *path)
+{
+ char *buf = realpath(path, NULL);
+ if (buf) {
+ gchar *str = g_strdup(buf);
+ free(buf);
+ return str;
+ } else {
+ return NULL;
+ }
+}
+
static void add_desktop_info(GDesktopAppInfo *info)
{
const char *quoted_executable = g_app_info_get_executable(G_APP_INFO(info));
@@ -117,11 +130,19 @@ static void add_desktop_info(GDesktopAppInfo *info)
if (executable && executable[0]) {
if (g_path_is_absolute(executable)) {
- add_desktop_item_by_exec(executable, info, 4000);
+ gchar *resolved_exec = resolve_path(executable);
+ add_desktop_item_by_exec(resolved_exec, info, 4000);
+ g_free(resolved_exec);
} else {
gchar *execpath = g_find_program_in_path(executable);
if (execpath) {
- add_desktop_item_by_exec(execpath, info, 0);
+ gchar *resolved_exec = resolve_path(execpath);
+ if (resolved_exec) {
+ add_desktop_item_by_exec(resolved_exec, info, 0);
+ } else {
+ g_warning("Could not realpath executable: '%s'", execpath);
+ }
+ g_free(resolved_exec);
} else {
g_warning("Could not find executable in path: '%s'", executable);
}
@@ -199,6 +220,7 @@ static GSList * matches_by_executable(const gchar *exec)
if (elist) {
return g_slist_copy(elist->list);
} else {
+ g_debug("Executable %s not matched", exec);
return NULL;
}
}
@@ -214,7 +236,7 @@ static GSList * matches_by_wmclass(const gchar *wmclass)
}
}
-const gchar * match_application_to_desktop_file(AppId *appid)
+const gchar * match_appid_to_desktopid(AppId *appid)
{
if (!init_matcher()) return NULL;
@@ -229,6 +251,12 @@ const gchar * match_application_to_desktop_file(AppId *appid)
if (list) {
list = g_slist_sort(list, desktop_item_compare);
+
+ for (GSList *l = list; l; l = l->next) {
+ DesktopItem *item = l->data;
+ g_debug(" match %d %s", item->priority, item->desktop_file);
+ }
+
DesktopItem *best = list->data;
g_slist_free(list);
return best->desktop_file;
diff --git a/libmdock/matcher.h b/libmdock/matcher.h
index 46fe4a6..3585605 100644
--- a/libmdock/matcher.h
+++ b/libmdock/matcher.h
@@ -22,6 +22,6 @@
#include "app-id.h"
-const gchar * match_application_to_desktop_file(AppId *appid);
+const gchar * match_appid_to_desktopid(AppId *appid);
#endif /* _MDOCK_MATCHER_H_ */
diff --git a/libmdock/mdock-enums.c b/libmdock/mdock-enums.c
deleted file mode 100644
index 6fb66a5..0000000
--- a/libmdock/mdock-enums.c
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/libmdock/mdock-enums.c.template b/libmdock/mdock-enums.c.template
new file mode 100644
index 0000000..551a860
--- /dev/null
+++ b/libmdock/mdock-enums.c.template
@@ -0,0 +1,38 @@
+/*** BEGIN file-header ***/
+#include "mdock-enums.h"
+#include "mdock-widget.h"
+#include "mdock-item.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id =
+ g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+
+ return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
diff --git a/libmdock/mdock-enums.h b/libmdock/mdock-enums.h
deleted file mode 100644
index c5f74bb..0000000
--- a/libmdock/mdock-enums.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015 Javier S. Pedro <dev.git@javispedro.com>
- *
- * This file is part of MDock.
- *
- * MDock is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MDock is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MDock. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _MDOCK_ENUMS_H_
-#define _MDOCK_ENUMS_H_
-
-
-
-#endif /* _MDOCK_ENUMS_H_ */
diff --git a/libmdock/mdock-enums.h.template b/libmdock/mdock-enums.h.template
new file mode 100644
index 0000000..d669580
--- /dev/null
+++ b/libmdock/mdock-enums.h.template
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef _MDOCK_ENUMS_H_
+#define _MDOCK_ENUMS_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GLIB_AVAILABLE_IN_ALL GType @enum_name@_get_type (void) G_GNUC_CONST;
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* _MDOCK_ENUMS_H_ */
+/*** END file-tail ***/
diff --git a/libmdock/mdock-item.h b/libmdock/mdock-item.h
index 42c3610..c934cf4 100644
--- a/libmdock/mdock-item.h
+++ b/libmdock/mdock-item.h
@@ -36,6 +36,11 @@ typedef struct _MDockItem MDockItem;
typedef struct _MDockItemClass MDockItemClass;
typedef struct _MDockItemPrivate MDockItemPrivate;
+typedef enum {
+ MDOCK_ITEM_TYPE_APPLICATION,
+ MDOCK_ITEM_TYPE_LAUNCHER
+} MDockItemType;
+
struct _MDockItem {
GtkBin parent;
@@ -49,7 +54,6 @@ struct _MDockItemClass {
GType mdock_item_get_type (void) G_GNUC_CONST;
MDockItem *mdock_item_new (void);
-
G_END_DECLS
#endif /* __MDOCK_ITEM_H__ */
diff --git a/libmdock/mdock-widget.c b/libmdock/mdock-widget.c
index 8da6869..defca10 100644
--- a/libmdock/mdock-widget.c
+++ b/libmdock/mdock-widget.c
@@ -48,9 +48,14 @@ static void handle_window_closed(MDockWidget *self, WnckWindow *window, WnckScre
static void handle_window_opened(MDockWidget *self, WnckWindow *window, WnckScreen *screen)
{
+ if (wnck_window_is_skip_tasklist(window)) {
+ return;
+ }
g_debug("Window opened: %s", wnck_window_get_name(window));
AppId *appid = app_id_from_window(window);
g_debug("%s %d %s %s %s", appid->host, appid->uid, appid->executable, appid->wm_class_class, appid->wm_class_name);
+ const gchar *desktopid = match_appid_to_desktopid(appid);
+ g_debug("desktopid: %s", desktopid);
}
static void mdock_widget_dispose(GObject *obj)