Hi, After filing this bug ( https://bugs.launchpad.net/ubuntu/+source/lxpanel/+bug/1630526) some time ago, I decided to try and make a patch to the existing pager.
The idea is that I'd love to be able to specify manually the number of rows for my workspaces, rather than it being calculated from the icon and height of the lxpanel. I believe the two numbers should have nothing to do with each other; the size of my icons should not dictate how I arrange my workspaces. It seems I have succeded in my intent. However, since I'm not an expert in GTK programming, I'd love is someone could take a look at my code and see whether (1) it makes sense and (2) if it could be possible to integrate this patch. In order to test this I have also made the pager into a standalone plugin, as normally it is a builtin one, and I didn't want to swap lxpanel each time to test things. I think this should not be a problem when actually integrating the patch, as the changes to make it standalone are orthogonal to the ones I did to add this feature. Let me know what you think! Best, Eugenio Bargiacchi
/* pager.c -- pager module of lxpanel project * * Copyright (C) 2009 Dongxu Li <song6s...@sourceforge.net> * 2012 Julien Lavergne <gi...@ubuntu.com> * 2014 Andriy Grytsenko <and...@rep.kiev.ua> * * This file is part of lxpanel. * * lxpanel 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, or (at your option) * any later version. * * lxpanel 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 sawfish; see the file COPYING. If not, write to * the Free Software Foundation, 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA. */ #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <libfm/fm-gtk.h> #include <glib/gi18n.h> #ifndef WNCK_I_KNOW_THIS_IS_UNSTABLE #define WNCK_I_KNOW_THIS_IS_UNSTABLE #endif #include <libwnck/libwnck.h> #include "plugin.h" typedef struct { WnckPager *pager; gint border; gint rows; } PagerData; /* command to configure desktop, it will be set by .config callback */ static const char *configure_command = NULL; static gboolean update_workspace(gpointer p) { PagerData *d = lxpanel_plugin_get_data(p); if (d->rows <= 0) d->rows = 1; wnck_pager_set_n_rows(d->pager, d->rows); return FALSE; } static void on_realize(GtkWidget *p, LXPanel *panel) { PagerData *d = lxpanel_plugin_get_data(p); /* set geometry */ wnck_pager_set_orientation(d->pager, panel_get_orientation(panel)); update_workspace(p); } static void on_size_allocate(GtkWidget *p, GdkRectangle *allocation, LXPanel *panel) { /* g_debug("pager: on_size_allocate(): %dx%d", allocation->width, allocation->height); */ on_realize(p, panel); } static GtkWidget *pager_constructor(LXPanel *panel, config_setting_t *settings) { GtkWidget *p, *w; PagerData *d; int border = 1; /* NOTE: old 'pager' used 2, WnckPager has 1, need 1 more */ /* FIXME: use some global setting for border */ #if GTK_CHECK_VERSION(3, 0, 0) w = wnck_pager_new(); #else w = wnck_pager_new(NULL); #endif g_return_val_if_fail(w != NULL, NULL); d = g_new(PagerData, 1); d->pager = WNCK_PAGER(w); d->border = border; d->rows = 2; p = gtk_event_box_new(); gtk_widget_set_has_window(p, FALSE); lxpanel_plugin_set_data(p, d, g_free); /* we cannot configure pager until it added into widgets hierarchy */ g_signal_connect(p, "realize", G_CALLBACK(on_realize), panel); g_signal_connect(p, "size-allocate", G_CALLBACK(on_size_allocate), panel); wnck_pager_set_display_mode(d->pager, WNCK_PAGER_DISPLAY_CONTENT); gtk_widget_show(w); /* add an additional container to setup a border */ w = gtk_event_box_new(); gtk_widget_set_has_window(w, FALSE); gtk_container_set_border_width(GTK_CONTAINER(w), border); gtk_container_add(GTK_CONTAINER(w), (GtkWidget*)d->pager); gtk_widget_show(w); gtk_container_add(GTK_CONTAINER(p), w); return p; } /* this is a modified version of patch from Lubuntu */ static GtkWidget *pager_configure(LXPanel *panel, GtkWidget *p) { if (configure_command) { fm_launch_command_simple(NULL, NULL, G_APP_INFO_CREATE_NONE, configure_command, NULL); } GtkWidget *dialog; PagerData *d = lxpanel_plugin_get_data(p); dialog = lxpanel_generic_config_dlg(_("Workspace Rows"), panel, update_workspace, p, _("Rows Number"), &d->rows, CONF_TYPE_INT, NULL); return dialog; } static void pager_menu_callback(GtkWidget *widget, gpointer data) { gtk_widget_set_sensitive(widget, FALSE); } static gboolean pager_update_context_menu(GtkWidget *plugin, GtkMenu *menu) { GdkScreen *screen = gtk_widget_get_screen(plugin); const char *wm_name = gdk_x11_screen_get_window_manager_name(screen); char *path = NULL; /* update configure_command */ configure_command = NULL; if (g_strcmp0(wm_name, "Openbox") == 0) { if ((path = g_find_program_in_path("obconf"))) { configure_command = "obconf --tab 6"; } } else if (g_strcmp0(wm_name, "compiz") == 0) { if ((path = g_find_program_in_path("ccsm"))) { configure_command = "ccsm"; } else if ((path = g_find_program_in_path("simple-ccsm"))) { configure_command = "simple-ccsm"; } } /* FIXME: support other WMs */ if (configure_command == NULL) { /* disable 'Settings' menu item */ gtk_container_foreach(GTK_CONTAINER(menu), pager_menu_callback, NULL); } /* FIXME: else replace 'Settings' item label with "Launch Workspaces Configurator (%s)" */ g_free(path); return FALSE; } static void pager_panel_configuration_changed(LXPanel *panel, GtkWidget *p) { on_realize(p, panel); } FM_DEFINE_MODULE(lxpanel_gtk, mypager) /* Plugin descriptor. */ LXPanelPluginInit fm_module_init_lxpanel_gtk = { .name = N_("My Desktop Pager"), .description = N_("Simple pager plugin"), .new_instance = pager_constructor, .config = pager_configure, .update_context_menu = pager_update_context_menu, .reconfigure = pager_panel_configuration_changed };
pager_diff
Description: Binary data
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________ Lxde-list mailing list Lxde-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxde-list