[gnome-applets/wip/muktupavels/window-title] window-title: port to libgnome-panel
- From: Alberts MuktupÄvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/muktupavels/window-title] window-title: port to libgnome-panel
- Date: Mon, 30 Mar 2020 18:55:51 +0000 (UTC)
commit 6d2595a0e4646ca03b86f31d50c8ec3d5293a12a
Author: Alberts MuktupÄvels <alberts muktupavels gmail com>
Date: Mon Mar 30 21:29:50 2020 +0300
window-title: port to libgnome-panel
Makefile.am | 2 -
configure.ac | 3 +-
gnome-applets/Makefile.am | 4 +
gnome-applets/ga-module.c | 15 +-
gnome-applets/window-title/Makefile.am | 36 +++++
.../window-title}/preferences.c | 133 ++++--------------
.../window-title}/preferences.h | 9 +-
gnome-applets/window-title/window-title-menu.xml | 14 ++
.../window-title/window-title-private.h | 56 ++------
.../window-title/window-title.c | 154 +++++++++------------
gnome-applets/window-title/window-title.h | 30 ++++
.../window-title/window-title.ui | 0
po/POTFILES.in | 6 +-
po/POTFILES.skip | 1 -
window-title/Makefile.am | 64 ---------
...nome.panel.WindowTitleApplet.panel-applet.in.in | 16 ---
16 files changed, 213 insertions(+), 330 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3d5cdd0ba..48ec6e587 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,6 @@ always_built_SUBDIRS = \
multiload \
sticky-notes \
window-buttons \
- window-title \
$(NULL)
SUBDIRS = \
@@ -32,7 +31,6 @@ DIST_SUBDIRS = \
multiload \
sticky-notes \
window-buttons \
- window-title \
tracker-search-bar \
$(NULL)
diff --git a/configure.ac b/configure.ac
index 5bd42ec45..9d4d979fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -353,6 +353,7 @@ AC_CONFIG_FILES([
gnome-applets/timer/Makefile
gnome-applets/trash/Makefile
gnome-applets/window-picker/Makefile
+ gnome-applets/window-title/Makefile
help/Makefile
help/accessx-status/Makefile
@@ -391,8 +392,6 @@ AC_CONFIG_FILES([
window-buttons/Makefile
window-buttons/themes/Makefile
-
- window-title/Makefile
])
AC_OUTPUT
diff --git a/gnome-applets/Makefile.am b/gnome-applets/Makefile.am
index d2e0ca52f..b653214c4 100644
--- a/gnome-applets/Makefile.am
+++ b/gnome-applets/Makefile.am
@@ -14,6 +14,7 @@ SUBDIRS = \
timer \
trash \
window-picker \
+ window-title \
$(NULL)
gnome_applets_libdir = $(GNOME_PANEL_MODULES_DIR)
@@ -50,6 +51,7 @@ org_gnome_gnome_applets_la_LIBADD = \
$(top_builddir)/gnome-applets/timer/libtimer-applet.la \
$(top_builddir)/gnome-applets/trash/libtrash-applet.la \
$(top_builddir)/gnome-applets/window-picker/libwindow-picker-applet.la \
+ $(top_builddir)/gnome-applets/window-title/libwindow-title-applet.la \
$(GNOME_PANEL_LIBS) \
$(NULL)
@@ -133,6 +135,8 @@ ui_files = \
trash/trash-menu.xml \
window-picker/wp-menu.xml \
window-picker/wp-preferences-dialog.ui \
+ window-title/window-title.ui \
+ window-title/window-title-menu.xml \
$(NULL)
if BUILD_CPUFREQ_APPLET
diff --git a/gnome-applets/ga-module.c b/gnome-applets/ga-module.c
index 29da2769b..7dffddbdb 100644
--- a/gnome-applets/ga-module.c
+++ b/gnome-applets/ga-module.c
@@ -36,6 +36,7 @@
#include "timer/timer-applet.h"
#include "trash/trash-applet.h"
#include "window-picker/wp-applet.h"
+#include "window-title/window-title.h"
static GpAppletInfo *
ga_get_applet_info (const char *id)
@@ -139,6 +140,13 @@ ga_get_applet_info (const char *id)
description = _("Shows a list of icons for the open windows.");
icon_name = "preferences-system-windows";
}
+ else if (g_strcmp0 (id, "window-title") == 0)
+ {
+ type_func = wt_applet_get_type;
+ name = _("Window Title");
+ description = _("Window title for your GNOME Panel");
+ icon_name = "windowtitle-applet";
+ }
else
{
g_assert_not_reached ();
@@ -177,11 +185,13 @@ ga_get_applet_id_from_iid (const char *iid)
return "netspeed";
else if (g_strcmp0 (iid, "TimerAppletFactory::TimerApplet") == 0)
return "timer";
+ else if (g_strcmp0 (iid, "TrashAppletFactory::TrashApplet") == 0)
+ return "trash";
else if (g_strcmp0 (iid, "WindowPickerFactory::WindowPicker") == 0 ||
g_strcmp0 (iid, "org.gnome.gnome-applets.window-picker::window-picker") == 0)
return "window-picker";
- else if (g_strcmp0 (iid, "TrashAppletFactory::TrashApplet") == 0)
- return "trash";
+ else if (g_strcmp0 (iid, "WindowTitleAppletFactory::WindowTitleApplet") == 0)
+ return "window-title";
return NULL;
}
@@ -214,6 +224,7 @@ gp_module_load (GpModule *module)
"timer",
"trash",
"window-picker",
+ "window-title",
NULL);
gp_module_set_get_applet_info (module, ga_get_applet_info);
diff --git a/gnome-applets/window-title/Makefile.am b/gnome-applets/window-title/Makefile.am
new file mode 100755
index 000000000..743034f2b
--- /dev/null
+++ b/gnome-applets/window-title/Makefile.am
@@ -0,0 +1,36 @@
+NULL =
+
+noinst_LTLIBRARIES = libwindow-title-applet.la
+
+libwindow_title_applet_la_CPPFLAGS = \
+ -DG_LOG_DOMAIN=\"org.gnome.gnome-applets.window-title\" \
+ -DG_LOG_USE_STRUCTURED=1 \
+ $(NULL)
+
+libwindow_title_applet_la_CFLAGS = \
+ $(GNOME_PANEL_CFLAGS) \
+ $(LIBWNCK_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(AM_CFLAGS) \
+ $(NULL)
+
+libwindow_title_applet_la_SOURCES = \
+ window-title-private.h \
+ window-title.c \
+ window-title.h \
+ preferences.c \
+ preferences.h \
+ $(NULL)
+
+libwindow_title_applet_la_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(AM_LDFLAGS) \
+ $(NULL)
+
+libwindow_title_applet_la_LIBADD = \
+ $(GNOME_PANEL_LIBS) \
+ $(LIBWNCK_LIBS) \
+ $(LIBM) \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/window-title/preferences.c b/gnome-applets/window-title/preferences.c
similarity index 74%
rename from window-title/preferences.c
rename to gnome-applets/window-title/preferences.c
index b099c40b3..2116d0994 100755
--- a/window-title/preferences.c
+++ b/gnome-applets/window-title/preferences.c
@@ -18,22 +18,15 @@
* Andrej Belcijan <{andrejx} at {gmail.com}>
*/
+#include "config.h"
#include "preferences.h"
-/* prototypes */
-void cb_only_maximized (GtkButton *, WTApplet *);
-void cb_click_effect (GtkButton *, WTApplet *);
-void cb_hide_on_unmaximized (GtkButton *, WTApplet *);
-void reloadWidgets(WTApplet *);
-void toggleHidden(WTApplet *);
-void setAlignment(WTApplet *, gdouble);
-void properties_close (GtkButton *, WTApplet *);
-void savePreferences(WTPreferences *, WTApplet *);
-WTPreferences *loadPreferences(WTApplet *);
-gchar* getCfgValue(FILE *, gchar *);
+static void properties_close (GtkButton *, WTApplet *);
-void savePreferences(WTPreferences *wtp, WTApplet *wtapplet) {
-#if PLAINTEXT_CONFIG == 0
+static void
+savePreferences (WTPreferences *wtp,
+ WTApplet *wtapplet)
+{
g_settings_set_boolean (wtapplet->settings, CFG_ONLY_MAXIMIZED, wtp->only_maximized);
g_settings_set_boolean (wtapplet->settings, CFG_HIDE_ON_UNMAXIMIZED, wtp->hide_on_unmaximized);
g_settings_set_boolean (wtapplet->settings, CFG_HIDE_ICON, wtp->hide_icon);
@@ -49,34 +42,14 @@ void savePreferences(WTPreferences *wtp, WTApplet *wtapplet) {
g_settings_set_string (wtapplet->settings, CFG_TITLE_ACTIVE_COLOR_FG, wtp->title_active_color);
g_settings_set_string (wtapplet->settings, CFG_TITLE_INACTIVE_FONT, wtp->title_inactive_font);
g_settings_set_string (wtapplet->settings, CFG_TITLE_INACTIVE_COLOR_FG, wtp->title_inactive_color);
-#else
- FILE *cfg = g_fopen (g_strconcat(g_get_home_dir(),"/",FILE_CONFIGFILE, NULL), "w");
-
- fprintf(cfg, "%s %d\n", CFG_ONLY_MAXIMIZED, wtp->only_maximized);
- fprintf(cfg, "%s %d\n", CFG_HIDE_ON_UNMAXIMIZED, wtp->hide_on_unmaximized);
- fprintf(cfg, "%s %d\n", CFG_HIDE_ICON, wtp->hide_icon);
- fprintf(cfg, "%s %d\n", CFG_HIDE_TITLE, wtp->hide_title);
- fprintf(cfg, "%s %d\n", CFG_SWAP_ORDER, wtp->swap_order);
- fprintf(cfg, "%s %d\n", CFG_EXPAND_APPLET, wtp->expand_applet);
- fprintf(cfg, "%s %d\n", CFG_CUSTOM_STYLE, wtp->custom_style);
- fprintf(cfg, "%s %d\n", CFG_SHOW_WINDOW_MENU, wtp->show_window_menu);
- fprintf(cfg, "%s %d\n", CFG_SHOW_TOOLTIPS, wtp->show_tooltips);
- fprintf(cfg, "%s %f\n", CFG_ALIGNMENT, wtp->alignment);
- fprintf(cfg, "%s %d\n", CFG_TITLE_SIZE, wtp->title_size);
- fprintf(cfg, "%s %s\n", CFG_TITLE_ACTIVE_FONT, wtp->title_active_font);
- fprintf(cfg, "%s %s\n", CFG_TITLE_ACTIVE_COLOR_FG, wtp->title_active_color);
- fprintf(cfg, "%s %s\n", CFG_TITLE_INACTIVE_FONT, wtp->title_inactive_font);
- fprintf(cfg, "%s %s\n", CFG_TITLE_INACTIVE_COLOR_FG, wtp->title_inactive_color);
-
- fclose (cfg);
-#endif
}
/* Get our properties (the only properties getter that should be called) */
-WTPreferences *loadPreferences(WTApplet *wtapplet) {
+WTPreferences *
+wt_applet_load_preferences (WTApplet *wtapplet)
+{
WTPreferences *wtp = g_new0(WTPreferences, 1);
-#if PLAINTEXT_CONFIG == 0
wtp->only_maximized = g_settings_get_boolean(wtapplet->settings, CFG_ONLY_MAXIMIZED);
wtp->hide_on_unmaximized = g_settings_get_boolean(wtapplet->settings, CFG_HIDE_ON_UNMAXIMIZED);
wtp->hide_icon = g_settings_get_boolean(wtapplet->settings, CFG_HIDE_ICON);
@@ -92,79 +65,22 @@ WTPreferences *loadPreferences(WTApplet *wtapplet) {
wtp->title_active_color = g_settings_get_string(wtapplet->settings, CFG_TITLE_ACTIVE_COLOR_FG);
wtp->title_inactive_font = g_settings_get_string(wtapplet->settings, CFG_TITLE_INACTIVE_FONT);;
wtp->title_inactive_color = g_settings_get_string(wtapplet->settings, CFG_TITLE_INACTIVE_COLOR_FG);
-#else
- FILE *cfg = g_fopen (g_strconcat(g_get_home_dir(),"/",FILE_CONFIGFILE,NULL),"r");
-
- if (cfg) {
- wtp->only_maximized = g_ascii_strtod(getCfgValue(cfg,CFG_ONLY_MAXIMIZED),NULL);
- wtp->hide_on_unmaximized = g_ascii_strtod(getCfgValue(cfg,CFG_HIDE_ON_UNMAXIMIZED),NULL);
- wtp->hide_icon = g_ascii_strtod(getCfgValue(cfg,CFG_HIDE_ICON),NULL);
- wtp->hide_title = g_ascii_strtod(getCfgValue(cfg,CFG_HIDE_TITLE),NULL);
- wtp->alignment = g_ascii_strtod(getCfgValue(cfg,CFG_ALIGNMENT),NULL);
- wtp->swap_order = g_ascii_strtod(getCfgValue(cfg,CFG_SWAP_ORDER),NULL);
- wtp->expand_applet = g_ascii_strtod(getCfgValue(cfg,CFG_EXPAND_APPLET),NULL);
- wtp->custom_style = g_ascii_strtod(getCfgValue(cfg,CFG_CUSTOM_STYLE),NULL);
- wtp->show_window_menu = g_ascii_strtod(getCfgValue(cfg,CFG_SHOW_WINDOW_MENU),NULL);
- wtp->show_tooltips = g_ascii_strtod(getCfgValue(cfg,CFG_SHOW_TOOLTIPS),NULL);
- wtp->title_size = g_ascii_strtod(getCfgValue(cfg,CFG_TITLE_SIZE),NULL);
- wtp->title_active_font = getCfgValue(cfg,CFG_TITLE_ACTIVE_FONT);
- wtp->title_active_color = getCfgValue(cfg,CFG_TITLE_ACTIVE_COLOR_FG);
- wtp->title_inactive_font = getCfgValue(cfg,CFG_TITLE_INACTIVE_FONT);
- wtp->title_inactive_color = getCfgValue(cfg,CFG_TITLE_INACTIVE_COLOR_FG);
-
- fclose (cfg);
- } else {
- // Defaults if the file doesn't exist
-
- wtp->only_maximized = TRUE;
- wtp->hide_on_unmaximized = FALSE;
- wtp->hide_icon = FALSE;
- wtp->hide_title = FALSE;
- wtp->alignment = 0.5;
- wtp->swap_order = FALSE;
- wtp->expand_applet = TRUE;
- wtp->custom_style = TRUE;
- wtp->show_window_menu = FALSE;
- wtp->show_tooltips = FALSE;
- wtp->title_size = 16;
- wtp->title_active_font = "Sans 10";
- wtp->title_active_color = "#FFFFFF";
- wtp->title_inactive_font = "Sans 10";
- wtp->title_inactive_color = "#808080";
-
- savePreferences(wtp,wtapplet);
- }
-#endif
return wtp;
}
-#if PLAINTEXT_CONFIG != 0
-/* Returns a string value of the specified configuration parameter (key) */
-// TODO: It wouldn't be too bad if we had this function in a common file instead of duplicating it for both
applets
-gchar* getCfgValue(FILE *f, gchar *key) {
- gchar tmp[256] = {0x0};
- long int pos = ftell(f);
-
- while (f!=NULL && fgets(tmp,sizeof(tmp),f)!=NULL) {
- if (g_strrstr(tmp, key))
- break;
- }
-
- gchar *r = g_strndup(tmp+strlen(key)+1,strlen(tmp)-strlen(key)+1);
- g_strstrip(r);
-
- fseek(f,pos,SEEK_SET);
- return r;
-}
-#endif
-
-void cb_only_maximized(GtkButton *button, WTApplet *wtapplet) {
+static void
+cb_only_maximized (GtkButton *button,
+ WTApplet *wtapplet)
+{
wtapplet->prefs->only_maximized = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
savePreferences(wtapplet->prefs, wtapplet);
}
-void cb_hide_on_unmaximized(GtkButton *button, WTApplet *wtapplet) {
+static void
+cb_hide_on_unmaximized (GtkButton *button,
+ WTApplet *wtapplet)
+{
wtapplet->prefs->hide_on_unmaximized = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
savePreferences(wtapplet->prefs, wtapplet);
wt_applet_update_title(wtapplet);
@@ -176,7 +92,7 @@ cb_hide_icon (GtkButton *button,
{
wtapplet->prefs->hide_icon = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
savePreferences(wtapplet->prefs, wtapplet);
- toggleHidden (wtapplet);
+ wt_applet_toggle_hidden (wtapplet);
}
static void
@@ -185,7 +101,7 @@ cb_hide_title (GtkButton *button,
{
wtapplet->prefs->hide_title = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
savePreferences(wtapplet->prefs, wtapplet);
- toggleHidden(wtapplet);
+ wt_applet_toggle_hidden (wtapplet);
}
static void
@@ -194,7 +110,7 @@ cb_swap_order (GtkButton *button,
{
wtapplet->prefs->swap_order = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button));
savePreferences(wtapplet->prefs, wtapplet);
- reloadWidgets(wtapplet);
+ wt_applet_reload_widgets(wtapplet);
}
static void
@@ -239,7 +155,7 @@ static void cb_alignment_changed(GtkRange *range, WTApplet *wtapplet)
{
wtapplet->prefs->alignment = gtk_range_get_value(range);
savePreferences(wtapplet->prefs, wtapplet);
- setAlignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
+ wt_applet_set_alignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
}
static void cb_font_active_set(GtkFontButton *widget, WTApplet *wtapplet)
@@ -295,7 +211,7 @@ wt_applet_properties_cb (GSimpleAction *action,
if(wtapplet->window_prefs) {
gtk_window_present(GTK_WINDOW(wtapplet->window_prefs));
} else {
- gtk_builder_add_from_file (wtapplet->prefbuilder, PATH_UI_PREFS, NULL);
+ gtk_builder_add_from_resource (GRESOURCE_PREFIX "/ui/window-title.ui", NULL);
wtapplet->window_prefs = GTK_WIDGET (gtk_builder_get_object (wtapplet->prefbuilder,
"properties"));
}
//gtk_builder_connect_signals (wtapplet->prefbuilder, NULL); // no need for now
@@ -358,7 +274,10 @@ wt_applet_properties_cb (GSimpleAction *action,
}
/* Close the Properties dialog - we're not saving anything (it's already saved) */
-void properties_close (GtkButton *object, WTApplet *wtapplet) {
+static void
+properties_close (GtkButton *object,
+ WTApplet *wtapplet)
+{
gtk_widget_destroy(wtapplet->window_prefs);
wtapplet->window_prefs = NULL;
}
diff --git a/window-title/preferences.h b/gnome-applets/window-title/preferences.h
similarity index 84%
rename from window-title/preferences.h
rename to gnome-applets/window-title/preferences.h
index 151bdd36b..114f32f04 100644
--- a/window-title/preferences.h
+++ b/gnome-applets/window-title/preferences.h
@@ -18,8 +18,15 @@
* Andrej Belcijan <{andrejx} at {gmail.com}>
*/
-#include "windowtitle.h"
+#ifndef WINDOW_TITLE_PREFERENCE_H
+#define WINDOW_TITLE_PREFERENCE_H
+
+#include "window-title-private.h"
+
+WTPreferences *wt_applet_load_preferences (WTApplet *wtapplet);
void wt_applet_properties_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data);
+
+#endif
diff --git a/gnome-applets/window-title/window-title-menu.xml
b/gnome-applets/window-title/window-title-menu.xml
new file mode 100644
index 000000000..6e37e1fe7
--- /dev/null
+++ b/gnome-applets/window-title/window-title-menu.xml
@@ -0,0 +1,14 @@
+<interface>
+ <menu id="window-title-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">window-title.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">window-title.about</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/window-title/windowtitle.h b/gnome-applets/window-title/window-title-private.h
similarity index 75%
rename from window-title/windowtitle.h
rename to gnome-applets/window-title/window-title-private.h
index 7759de5fd..6bc77ee23 100755
--- a/window-title/windowtitle.h
+++ b/gnome-applets/window-title/window-title-private.h
@@ -18,38 +18,17 @@
* Andrej Belcijan <{andrejx} at {gmail.com}>
*/
-#define PLAINTEXT_CONFIG 0
+#ifndef WINDOW_TITLE_PRIVATE_H
+#define WINDOW_TITLE_PRIVATE_H
-#ifndef __WT_APPLET_H__
-#define __WT_APPLET_H__
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <glib-object.h>
-#include <glib/gi18n.h>
-#include <panel-applet.h>
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
+#include "window-title.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
-#if PLAINTEXT_CONFIG == 1
-#include <glib/gstdio.h>
-#endif
-
#ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#endif
#include <libwnck/libwnck.h>
-/* static paths and stuff */
-#define APPLET_NAME "Window Title"
-#define APPLET_OAFIID "WindowTitleApplet"
-#define APPLET_OAFIID_FACTORY "WindowTitleAppletFactory"
-#define PATH_UI_PREFS GTK_BUILDERDIR"/windowtitle.ui"
-#define FILE_CONFIGFILE ".windowtitle"
#define ICON_WIDTH 16
#define ICON_HEIGHT 16
#define ICON_PADDING 5
@@ -73,13 +52,6 @@
G_BEGIN_DECLS
-#define WT_TYPE_APPLET wt_applet_get_type()
-#define WT_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WT_TYPE_APPLET, WTApplet))
-#define WT_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WT_TYPE_APPLET, WTAppletClass))
-#define WT_IS_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WT_TYPE_APPLET))
-#define WT_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WT_TYPE_APPLET))
-#define WT_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WT_TYPE_APPLET, WTAppletClass))
-
/* Applet properties (things that get saved) */
typedef struct {
gboolean only_maximized, // [T/F] Only track maximized windows
@@ -99,9 +71,10 @@ typedef struct {
gdouble alignment; // Title alignment [0=left,
0.5=center, 1=right]
} WTPreferences;
-/* WBApplet definition (inherits from PanelApplet) */
-typedef struct {
- PanelApplet parent;
+struct _WTApplet
+{
+ GpApplet parent;
+
GSettings *settings;
/* Widgets */
@@ -134,24 +107,23 @@ typedef struct {
gboolean focused; // [T/F] Window state (focused or
unfocused)
GdkPixbufRotation angle; // Applet angle
- PanelAppletOrient orient; // Panel orientation
+ GtkPositionType position; // Panel orientation
gint asize; // Applet allocation size
gint *size_hints; // Applet size hints
GtkPackType packtype; // Packaging direction of buttons
/* GtkBuilder */
GtkBuilder *prefbuilder; // Glade GtkBuilder for the preferences
-} WTApplet;
+};
-typedef struct {
- PanelAppletClass applet_class;
-} WTAppletClass;
-
-GType wt_applet_get_type (void);
-WTApplet* wt_applet_new (void);
+void wt_applet_reload_widgets (WTApplet *wtapplet);
+void wt_applet_toggle_hidden (WTApplet *wtapplet);
+void wt_applet_set_alignment (WTApplet *wtapplet,
+ gdouble alignment);
void wt_applet_update_title (WTApplet *wtapplet);
void wt_applet_toggle_expand (WTApplet *wtapplet);
G_END_DECLS
+
#endif
diff --git a/window-title/windowtitle.c b/gnome-applets/window-title/window-title.c
similarity index 86%
rename from window-title/windowtitle.c
rename to gnome-applets/window-title/window-title.c
index 1b4d4ab52..dc5815628 100755
--- a/window-title/windowtitle.c
+++ b/gnome-applets/window-title/window-title.c
@@ -18,53 +18,33 @@
* Andrej Belcijan <{andrejx} at {gmail.com}>
*/
-#include "windowtitle.h"
+#include "config.h"
+#include "window-title.h"
+
+#include <glib/gi18n-lib.h>
+
#include "preferences.h"
-/* Prototypes */
-static void applet_change_orient (PanelApplet *, PanelAppletOrient, WTApplet *);
-static void active_workspace_changed (WnckScreen *, WnckWorkspace *, WTApplet *);
-static void active_window_changed (WnckScreen *, WnckWindow *, WTApplet *);
+static void init_wtapplet (WTApplet *wtapplet);
static void active_window_state_changed (WnckWindow *, WnckWindowState, WnckWindowState, WTApplet *);
static void active_window_nameicon_changed (WnckWindow *, WTApplet *);
static void umaxed_window_state_changed (WnckWindow *, WnckWindowState, WnckWindowState, WTApplet *);
static void umaxed_window_nameicon_changed (WnckWindow *, WTApplet *);
-static void viewports_changed (WnckScreen *, WTApplet *);
-static void window_closed (WnckScreen *, WnckWindow *, WTApplet *);
-static void window_opened (WnckScreen *, WnckWindow *, WTApplet *);
static void about_cb ( GSimpleAction *, GVariant *, gpointer );
-static WnckWindow *getRootWindow (WnckScreen *);
-static WnckWindow *getUpperMaximized (WTApplet *);
-//const gchar *getCheckBoxGConfKey (gushort);
-void setAlignment(WTApplet *, gdouble);
-void placeWidgets (WTApplet *);
-void reloadWidgets (WTApplet *);
-void toggleHidden(WTApplet *);
-void savePreferences(WTPreferences *, WTApplet *);
-WTPreferences *loadPreferences(WTApplet *);
-//gchar *getButtonLayoutGConf(WTApplet *, gboolean);
-
-G_DEFINE_TYPE (WTApplet, wt_applet, PANEL_TYPE_APPLET);
+
+G_DEFINE_TYPE (WTApplet, wt_applet, GP_TYPE_APPLET)
static GActionEntry windowtitle_menu_actions [] = {
{ "preferences", wt_applet_properties_cb, NULL, NULL, NULL },
- { "about", about_cb, NULL, NULL, NULL }
+ { "about", about_cb, NULL, NULL, NULL },
+ { NULL }
};
-static const gchar windowtitle_menu_items [] =
- "<section>"
- "<item>"
- "<attribute name=\"label\">Preferences</attribute>"
- "<attribute name=\"action\">windowtitle.preferences</attribute>"
- "</item>"
- "<item>"
- "<attribute name=\"label\">About</attribute>"
- "<attribute name=\"action\">windowtitle.about</attribute>"
- "</item>"
- "</section>";
-
-WTApplet* wt_applet_new (void) {
- return g_object_new (WT_TYPE_APPLET, NULL);
+static void
+wt_applet_constructed (GObject *object)
+{
+ G_OBJECT_CLASS (wt_applet_parent_class)->constructed (object);
+ init_wtapplet (WT_APPLET (object));
}
static void
@@ -143,11 +123,14 @@ wt_applet_class_init (WTAppletClass *self_class)
object_class = G_OBJECT_CLASS (self_class);
+ object_class->constructed = wt_applet_constructed;
object_class->dispose = wt_applet_dispose;
}
-static void wt_applet_init(WTApplet *wtapplet) {
- // Not required
+static void
+wt_applet_init (WTApplet *self)
+{
+ wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
}
/* The About dialog */
@@ -348,18 +331,20 @@ void
wt_applet_toggle_expand (WTApplet *wtapplet)
{
if (wtapplet->prefs->expand_applet) {
- panel_applet_set_flags (PANEL_APPLET (wtapplet), PANEL_APPLET_EXPAND_MINOR |
PANEL_APPLET_EXPAND_MAJOR);
+ gp_applet_set_flags (GP_APPLET (wtapplet), GP_APPLET_FLAGS_EXPAND_MINOR |
GP_APPLET_FLAGS_EXPAND_MAJOR);
} else {
// We must have a handle due to bug https://bugzilla.gnome.org/show_bug.cgi?id=556355
- // panel_applet_set_flags (PANEL_APPLET (wtapplet), PANEL_APPLET_EXPAND_MINOR |
PANEL_APPLET_EXPAND_MAJOR | PANEL_APPLET_HAS_HANDLE);
- panel_applet_set_flags (PANEL_APPLET (wtapplet), PANEL_APPLET_EXPAND_MINOR);
+ // gp_applet_set_flags (GP_APPLET (wtapplet), GP_APPLET_FLAGS_EXPAND_MINOR |
GP_APPLET_FLAGS_EXPAND_MAJOR | GP_APPLET_FLAGS_HAS_HANDLE);
+ gp_applet_set_flags (GP_APPLET (wtapplet), GP_APPLET_FLAGS_EXPAND_MINOR);
}
- reloadWidgets(wtapplet);
- setAlignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
+ wt_applet_reload_widgets(wtapplet);
+ wt_applet_set_alignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
}
/* Hide/unhide stuff according to preferences */
-void toggleHidden (WTApplet *wtapplet) {
+void
+wt_applet_toggle_hidden (WTApplet *wtapplet)
+{
if (wtapplet->prefs->hide_icon) {
gtk_widget_hide (GTK_WIDGET(wtapplet->icon));
} else {
@@ -382,15 +367,16 @@ void toggleHidden (WTApplet *wtapplet) {
gtk_widget_show_all(GTK_WIDGET(wtapplet));
}
-/* Triggered when a different panel orientation is detected */
-static void applet_change_orient (PanelApplet *panelapplet,
- PanelAppletOrient orient,
- WTApplet *wtapplet)
+static void
+placement_changed_cb (GpApplet *applet,
+ GtkOrientation orientation,
+ GtkPositionType position,
+ WTApplet *wtapplet)
{
- if (orient != wtapplet->orient) {
- wtapplet->orient = orient;
+ if (position != wtapplet->position) {
+ wtapplet->position = position;
- reloadWidgets(wtapplet);
+ wt_applet_reload_widgets(wtapplet);
wt_applet_update_title(wtapplet);
}
}
@@ -636,12 +622,13 @@ static gboolean title_clicked (GtkWidget *title,
}
/* Places widgets in box accordingly with angle and order */
-void placeWidgets (WTApplet *wtapplet) {
-
+static void
+placeWidgets (WTApplet *wtapplet)
+{
// TODO: merge all this... or not?
- if (wtapplet->orient == PANEL_APPLET_ORIENT_RIGHT) {
+ if (wtapplet->position == GTK_POS_LEFT) {
wtapplet->angle = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
- } else if (wtapplet->orient == PANEL_APPLET_ORIENT_LEFT) {
+ } else if (wtapplet->position == GTK_POS_RIGHT) {
wtapplet->angle = GDK_PIXBUF_ROTATE_CLOCKWISE;
} else {
wtapplet->angle = GDK_PIXBUF_ROTATE_NONE;
@@ -671,11 +658,12 @@ void placeWidgets (WTApplet *wtapplet) {
// Set alignment/orientation
gtk_label_set_angle( wtapplet->title, wtapplet->angle );
- setAlignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
+ wt_applet_set_alignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
}
-/* Reloads all widgets */
-void reloadWidgets (WTApplet *wtapplet) {
+void
+wt_applet_reload_widgets (WTApplet *wtapplet)
+{
g_object_ref(wtapplet->eb_icon);
g_object_ref(wtapplet->eb_title);
gtk_container_remove(GTK_CONTAINER(wtapplet->box), GTK_WIDGET(wtapplet->eb_icon));
@@ -686,7 +674,10 @@ void reloadWidgets (WTApplet *wtapplet) {
}
/* Sets alignment, min size, padding to title according to panel orientation */
-void setAlignment (WTApplet *wtapplet, gdouble alignment) {
+void
+wt_applet_set_alignment (WTApplet *wtapplet,
+ gdouble alignment)
+{
if (!wtapplet->prefs->expand_applet)
alignment = 0.0;
@@ -707,27 +698,29 @@ void setAlignment (WTApplet *wtapplet, gdouble alignment) {
}
}
-/* Do the actual applet initialization */
-static void init_wtapplet (PanelApplet *applet) {
- WTApplet *wtapplet;
+static void
+init_wtapplet (WTApplet *wtapplet)
+{
+ GpApplet *applet;
+ const char *menu_resource;
- wtapplet = WT_APPLET (applet);
+ applet = GP_APPLET (wtapplet);
- wtapplet->settings = panel_applet_settings_new (applet, WINDOWTITLE_GSCHEMA);
- wtapplet->prefs = loadPreferences(wtapplet);
+ wtapplet->settings = gp_applet_settings_new (applet, WINDOWTITLE_GSCHEMA);
+ wtapplet->prefs = wt_applet_load_preferences(wtapplet);
wtapplet->activescreen = wnck_screen_get_default();
wnck_screen_force_update(wtapplet->activescreen);
wtapplet->activeworkspace = wnck_screen_get_active_workspace(wtapplet->activescreen);
wtapplet->activewindow = wnck_screen_get_active_window(wtapplet->activescreen);
wtapplet->umaxedwindow = getUpperMaximized(wtapplet);
wtapplet->rootwindow = getRootWindow(wtapplet->activescreen);
- wtapplet->prefbuilder = gtk_builder_new();
+ wtapplet->prefbuilder = gtk_builder_new ();
wtapplet->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
wtapplet->icon = GTK_IMAGE(gtk_image_new());
wtapplet->title = GTK_LABEL(gtk_label_new(NULL));
wtapplet->eb_icon = GTK_EVENT_BOX(gtk_event_box_new());
wtapplet->eb_title = GTK_EVENT_BOX(gtk_event_box_new());
- wtapplet->orient = panel_applet_get_orient(applet);
+ wtapplet->position = gp_applet_get_position (applet);
wtapplet->size_hints = g_new(gint,2);
// Widgets to eventboxes, eventboxes to box
@@ -739,7 +732,7 @@ static void init_wtapplet (PanelApplet *applet) {
gtk_event_box_set_visible_window (wtapplet->eb_title, FALSE);
// Rotate & place elements
- setAlignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
+ wt_applet_set_alignment(wtapplet, (gdouble)wtapplet->prefs->alignment);
placeWidgets(wtapplet);
// Add box to applet
@@ -773,7 +766,7 @@ static void init_wtapplet (PanelApplet *applet) {
// g_signal_connect(G_OBJECT (wtapplet->title), "size-request", G_CALLBACK
(applet_title_size_request), wtapplet);
g_signal_connect(G_OBJECT (wtapplet), "size-allocate", G_CALLBACK (applet_size_allocate), wtapplet);
- g_signal_connect(G_OBJECT (wtapplet), "change-orient", G_CALLBACK (applet_change_orient), wtapplet);
+ g_signal_connect(G_OBJECT (wtapplet), "placement-changed", G_CALLBACK (placement_changed_cb),
wtapplet);
// Track active window changes
wtapplet->active_handler_state =
@@ -783,30 +776,11 @@ static void init_wtapplet (PanelApplet *applet) {
wtapplet->active_handler_icon =
g_signal_connect(G_OBJECT (wtapplet->activewindow), "icon-changed", G_CALLBACK
(active_window_nameicon_changed), wtapplet);
-
// Setup applet right-click menu
- GSimpleActionGroup *action_group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (action_group), windowtitle_menu_actions, G_N_ELEMENTS
(windowtitle_menu_actions), wtapplet);
- panel_applet_setup_menu (applet, windowtitle_menu_items, action_group, GETTEXT_PACKAGE);
- gtk_widget_insert_action_group (GTK_WIDGET (wtapplet), "windowtitle", G_ACTION_GROUP (action_group));
+ menu_resource = GRESOURCE_PREFIX "/ui/window-title-menu.xml";
+ gp_applet_setup_menu_from_resource (applet, menu_resource, windowtitle_menu_actions);
wt_applet_toggle_expand (wtapplet);
- toggleHidden (wtapplet); // Properly hide or show stuff
+ wt_applet_toggle_hidden (wtapplet); // Properly hide or show stuff
wt_applet_update_title (wtapplet);
}
-
-// Initial function that draws the applet
-static gboolean windowtitle_applet_factory (PanelApplet *applet, const gchar *iid, gpointer data) {
- if (strcmp (iid, APPLET_OAFIID) != 0) return FALSE;
-
- wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
-
- init_wtapplet (applet);
-
- return TRUE;
-}
-
-PANEL_APPLET_IN_PROCESS_FACTORY (APPLET_OAFIID_FACTORY,
- WT_TYPE_APPLET,
- windowtitle_applet_factory,
- NULL)
diff --git a/gnome-applets/window-title/window-title.h b/gnome-applets/window-title/window-title.h
new file mode 100644
index 000000000..d0443f133
--- /dev/null
+++ b/gnome-applets/window-title/window-title.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2020 Alberts MuktupÄvels
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WINDOW_TITLE_H
+#define WINDOW_TITLE_H
+
+#include <libgnome-panel/gp-applet.h>
+
+G_BEGIN_DECLS
+
+#define WT_TYPE_APPLET (wt_applet_get_type ())
+G_DECLARE_FINAL_TYPE (WTApplet, wt_applet, WT, APPLET, GpApplet)
+
+G_END_DECLS
+
+#endif
diff --git a/window-title/windowtitle.ui b/gnome-applets/window-title/window-title.ui
similarity index 100%
rename from window-title/windowtitle.ui
rename to gnome-applets/window-title/window-title.ui
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0ea4e054e..112f866ed 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -64,6 +64,9 @@ gnome-applets/window-picker/wp-applet.c
[type: gettext/glade]gnome-applets/window-picker/wp-menu.xml
[type: gettext/glade]gnome-applets/window-picker/wp-preferences-dialog.ui
gnome-applets/window-picker/wp-task-title.c
+[type: gettext/glade]gnome-applets/window-title/window-title.ui
+[type: gettext/glade]gnome-applets/window-title/window-title-menu.xml
+gnome-applets/window-title/window-title.c
mini-commander/src/about.c
mini-commander/src/cmd_completion.c
mini-commander/src/command_line.c
@@ -103,6 +106,3 @@ tracker-search-bar/src/tracker-results-window.c
[type: gettext/ini]window-buttons/org.gnome.panel.WindowButtonsApplet.panel-applet.in.in
window-buttons/windowbuttons.c
[type: gettext/glade]window-buttons/windowbuttons.ui
-[type: gettext/ini]window-title/org.gnome.panel.WindowTitleApplet.panel-applet.in.in
-window-title/windowtitle.c
-[type: gettext/glade]window-title/windowtitle.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index a25cc0825..fe5b59fec 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -23,4 +23,3 @@ multiload/org.gnome.applets.MultiLoadApplet.panel-applet.in
sticky-notes/data/org.gnome.applets.StickyNotesApplet.panel-applet.in
tracker-search-bar/data/org.gnome.panel.SearchBar.panel-applet.in
window-buttons/org.gnome.panel.WindowButtonsApplet.panel-applet.in
-window-title/org.gnome.panel.WindowTitleApplet.panel-applet.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]