Hi Andriy, thanks a lot for the comprehensive feedback.
On 01/20/17 23:33, Andrej N. Gritsenko wrote: > Hello! > > Enguerrand de Rochefort has written on Thursday, 19 January, at 0:18: > >> I am working on a patch for lxpanel that allows to configure taskbars such >> that they only show tasks on a specific workspace. That way, one can have >> one taskbar for each workspace and have it display all tasks on that (and >> only that) workspace. >> The behavior is similar to what the tint2 bar does. > > Well, taskbar has an option to show windows from only current desktop. Do > you mean your change is not for current one but for fixed one, right? Yes, that is exactly what I'd like to achieve. > >> At this point I got the functionality working but it must be configured by >> manually editing the configuration file. > >> What's missing is the extension of the configuration dialog, which I >> probably wouldn't bother to implement for myself but would be willing to >> take a crack at if you guys were interested to merge the change. (I have >> very little experience in c programming so do expect this to take a while...) > > It is not a big problem, it's what is collective development for - you > miss some element of feature, someone else adds/fixes it. > >> Before doing that (and creating a sourceforge account, or what's your >> preferred way of contributing code?) I just wanted to get some initial >> feedback on this. >> You can find my current diff below (created with git format-patch). > > Sourceforge account isn't required for a contribution, you may send a > patch here (as you did now), and request a git account later, after other > developers see your changes are sane enough. > >> Let me know what you think, >> kind regards > > Overall your change seems OK. Although I would rather name the field like > 'fixed_desktop_num' with value -1 to do current behavior (show all) and > working only if 'show_all_desks' is TRUE, to keep compatibility. Ok, I fully agree with the suggestion on variable naming and changed it accordingly. As far as the interaction with the 'show_all_desks' setting I am a bit confused, though. Personally, when I check a "show all desks" option I would expect the task bar to do just that - show tasks from all desktops - irrespective of other settings. For that reason, I left that behavior unchanged for now but if you still feel differently I am obviously happy to go ahead and change it... I extended the config dialog but I guess there is room for improvement. First off, the show_all_desks option and the fixed_desktop_num should probably be mutually exclusive, i.e. activation of the first should probably gray out the second or something like that. This goes back to the previous point as well. Unfortunately I have no idea how to achieve such a behavior. Second, I gave the spinner a range from -1 to 10 (hard coded), but in fact the upper limit should be the same as the current workspace count. Lastly, I did not adjust any of the localisation files. Do you use some automatic tool to do that or is that process as tedious as it looks? Anyway, you can find what I currently have at the bottom of this email. If you want to give me some pointers regarding the questions above I am happy to try and improve this further. Best regards Enguerrand > >> Enguerrand > > With best regards, > Andriy. >From 4cad59e01e5f2d7fb1e4c3288689baa976e21883 Mon Sep 17 00:00:00 2001 From: Enguerrand de Rochefort <sourcefo...@rochefort.de> Date: Wed, 25 Jan 2017 22:59:20 +0100 Subject: [PATCH] Taskbar supports fixed desktop numbers --- data/ui/launchtaskbar.glade | 62 ++++++++++++++++++++++++++++++++++++++++----- plugins/launchtaskbar.c | 17 +++++++++++-- plugins/task-button.c | 14 +++++++--- plugins/task-button.h | 5 ++-- 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/data/ui/launchtaskbar.glade b/data/ui/launchtaskbar.glade index 41a79b3..1f5bee5 100644 --- a/data/ui/launchtaskbar.glade +++ b/data/ui/launchtaskbar.glade @@ -13,6 +13,12 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment_fixed_desktop_num"> + <property name="lower">-1</property> + <property name="upper">10</property> + <property name="step_increment">1</property> + <property name="page_increment">2</property> + </object> <object class="GtkListStore" id="defined_store"> <columns> <!-- column-name icon --> @@ -338,6 +344,48 @@ </packing> </child> <child> + <object class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Fixed desktop number for task buttons (-1 disables the feature)</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">2</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="spinbutton_fixed_desktop_num"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">•</property> + <property name="primary_icon_activatable">False</property> + <property name="secondary_icon_activatable">False</property> + <property name="primary_icon_sensitive">True</property> + <property name="secondary_icon_sensitive">True</property> + <property name="adjustment">adjustment_fixed_desktop_num</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">3</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + <child> <object class="GtkCheckButton" id="checkbutton_mouse_wheel"> <property name="label" translatable="yes">Use mouse wheel</property> <property name="visible">True</property> @@ -348,7 +396,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">5</property> + <property name="position">6</property> </packing> </child> <child> @@ -362,7 +410,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">6</property> + <property name="position">7</property> </packing> </child> <child> @@ -376,7 +424,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">7</property> + <property name="position">8</property> </packing> </child> <child> @@ -390,7 +438,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">8</property> + <property name="position">9</property> </packing> </child> <child> @@ -404,7 +452,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">9</property> + <property name="position">10</property> </packing> </child> <child> @@ -446,7 +494,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">10</property> + <property name="position">11</property> </packing> </child> <child> @@ -488,7 +536,7 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">11</property> + <property name="position">12</property> </packing> </child> </object> diff --git a/plugins/launchtaskbar.c b/plugins/launchtaskbar.c index 81af676..28dceb6 100644 --- a/plugins/launchtaskbar.c +++ b/plugins/launchtaskbar.c @@ -119,6 +119,7 @@ struct LaunchTaskBarPlugin { GtkWidget * tb_icon_grid; /* Manager for taskbar buttons */ int number_of_desktops; /* Number of desktops, from NET_WM_NUMBER_OF_DESKTOPS */ int current_desktop; /* Current desktop, from NET_WM_CURRENT_DESKTOP */ + int fixed_desktop_num; /* Only tasks from this desktop are shown in the taskbar. */ guint dnd_delay_timer; /* Timer for drag and drop delay */ gboolean dnd_task_moving; /* User is currently moving a task button */ int icon_size; /* Size of task icons */ @@ -1008,6 +1009,7 @@ static void launchtaskbar_constructor_task(LaunchTaskBarPlugin *ltbp) ltbp->flags.icons_only = (tmp_int != 0); if (config_setting_lookup_int(s, "ShowAllDesks", &tmp_int)) ltbp->flags.show_all_desks = (tmp_int != 0); + config_setting_lookup_int(s, "FixedDesktopNum", <bp->fixed_desktop_num); if (config_setting_lookup_int(s, "SameMonitorOnly", &tmp_int)) ltbp->flags.same_monitor_only = (tmp_int != 0); if (config_setting_lookup_int(s, "DisableUpscale", &tmp_int)) @@ -1104,6 +1106,7 @@ static GtkWidget *_launchtaskbar_constructor(LXPanel *panel, config_setting_t *s ltbp->flags.tooltips = TRUE; ltbp->flags.icons_only = FALSE; ltbp->flags.show_all_desks = TRUE; + ltbp->fixed_desktop_num = ALL_WORKSPACES; ltbp->task_width_max = TASK_WIDTH_MAX; ltbp->spacing = 1; ltbp->flags.use_mouse_wheel = TRUE; @@ -1639,6 +1642,15 @@ static void on_spinbutton_spacing_value_changed(GtkSpinButton *p_spinbutton, gpo taskbar_apply_configuration(ltbp); } +static void on_spinbutton_fixed_desktop_num_value_changed(GtkSpinButton *p_spinbutton, gpointer p_data) +{ + LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data; + ltbp->fixed_desktop_num = gtk_spin_button_get_value(p_spinbutton); + //g_print("\ntb->spacing upd\n"); + config_group_set_int(ltbp->settings, "FixedDesktopNum", ltbp->fixed_desktop_num); + taskbar_apply_configuration(ltbp); +} + static gboolean on_defined_view_button_press_event(GtkWidget *p_widget, GdkEventButton *p_event, gpointer p_data) { LaunchTaskBarPlugin *lb = (LaunchTaskBarPlugin *)p_data; @@ -1799,6 +1811,7 @@ static GtkWidget *launchtaskbar_configure(LXPanel *panel, GtkWidget *p) SETUP_SPIN_BUTTON(spinbutton_max_width, task_width_max); SETUP_SPIN_BUTTON(spinbutton_spacing, spacing); + SETUP_SPIN_BUTTON(spinbutton_fixed_desktop_num, fixed_desktop_num); #undef SETUP_SPIN_BUTTON ltbp->config_dlg = dlg; @@ -1894,7 +1907,7 @@ static void taskbar_redraw(LaunchTaskBarPlugin * tb) icon_size -= 4; for (l = children; l; l = l->next) task_button_update(l->data, tb->current_desktop, tb->number_of_desktops, - mon, icon_size, tb->flags); + mon, icon_size, tb->flags, tb->fixed_desktop_num); g_list_free(children); } @@ -2162,7 +2175,7 @@ static void taskbar_add_new_window(LaunchTaskBarPlugin * tb, Window win, GList * return; /* some button accepted it, done */ task = task_button_new(win, tb->current_desktop, tb->number_of_desktops, - tb->panel, res_class, tb->flags); + tb->panel, res_class, tb->flags, tb->fixed_desktop_num); taskbar_add_task_button(tb, task); } diff --git a/plugins/task-button.c b/plugins/task-button.c index ea8ca9c..83eaad8 100644 --- a/plugins/task-button.c +++ b/plugins/task-button.c @@ -95,6 +95,7 @@ struct _TaskButton gint desktop; /* Current desktop of the button */ gint n_desktops; /* total number of desktops */ gint monitor; /* current monitor for the panel */ + gint fixed_desktop_num; /* only show task icons for windows on this desktop */ guint icon_size; /* Current value from last update */ TaskShowFlags flags; /* flags to show */ unsigned int set_bold :1; /* flat buttons only: TRUE if set bold */ @@ -206,7 +207,8 @@ static gboolean task_is_visible(TaskButton *b, TaskDetails *task) /* Desktop placement. */ return ((task->desktop == ALL_WORKSPACES) || - (task->desktop == b->desktop) || + (task->desktop == b->desktop && b->fixed_desktop_num == ALL_WORKSPACES) || + (task->desktop == b->fixed_desktop_num) || (b->flags.show_all_desks) || (b->flags.use_urgency_hint && task->urgency)); } @@ -1470,7 +1472,7 @@ static void task_button_init(TaskButton *self) /* creates new button and sets rendering options */ TaskButton *task_button_new(Window win, gint desk, gint desks, LXPanel *panel, - const char *res_class, TaskShowFlags flags) + const char *res_class, TaskShowFlags flags, gint fixed_desktop_num) { TaskButton *self = g_object_new(PANEL_TYPE_TASK_BUTTON, "relief", flags.flat_button ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL, @@ -1480,6 +1482,7 @@ TaskButton *task_button_new(Window win, gint desk, gint desks, LXPanel *panel, self->desktop = desk; self->n_desktops = desks; self->panel = panel; + self->fixed_desktop_num = fixed_desktop_num; self->monitor = panel_get_monitor(panel); self->icon_size = panel_get_icon_size(panel); if (flags.use_smaller_icons) @@ -1724,7 +1727,8 @@ gboolean task_button_window_reconfigured(TaskButton *button, Window win) /* updates rendering options */ void task_button_update(TaskButton *button, gint desk, gint desks, - gint mon, guint icon_size, TaskShowFlags flags) + gint mon, guint icon_size, TaskShowFlags flags, + gint fixed_desktop_num) { gboolean changed = FALSE, changed_icon = FALSE, changed_label = FALSE; @@ -1733,7 +1737,8 @@ void task_button_update(TaskButton *button, gint desk, gint desks, if (button->desktop != desk || button->monitor != mon || button->flags.show_all_desks != flags.show_all_desks - || button->flags.same_monitor_only != flags.same_monitor_only) + || button->flags.same_monitor_only != flags.same_monitor_only + || button->fixed_desktop_num != fixed_desktop_num) changed = TRUE; if (button->n_desktops != desks) task_button_reset_menu(gtk_widget_get_parent(GTK_WIDGET(button))); @@ -1762,6 +1767,7 @@ void task_button_update(TaskButton *button, gint desk, gint desks, button->monitor = mon; button->icon_size = icon_size; button->flags = flags; + button->fixed_desktop_num = fixed_desktop_num; if (changed) { diff --git a/plugins/task-button.h b/plugins/task-button.h index e6acc6d..ef3fba9 100644 --- a/plugins/task-button.h +++ b/plugins/task-button.h @@ -63,7 +63,7 @@ struct _TaskButtonClass /* creates new button and sets rendering options */ TaskButton *task_button_new(Window win, gint desk, gint desks, LXPanel *panel, - const char *cl, TaskShowFlags flags); + const char *cl, TaskShowFlags flags, gint fixed_desktop_num); gboolean task_button_has_window(TaskButton *button, Window win); /* removes windows from button, that are missing in list */ @@ -74,7 +74,8 @@ gboolean task_button_window_focus_changed(TaskButton *button, Window *win); gboolean task_button_window_reconfigured(TaskButton *button, Window win); /* updates rendering options */ void task_button_update(TaskButton *button, gint desk, gint desks, - gint mon, guint icon_size, TaskShowFlags flags); + gint mon, guint icon_size, TaskShowFlags flags, + gint fixed_desktop_num); void task_button_set_flash_state(TaskButton *button, gboolean state); /* adds task only if it's the same class */ gboolean task_button_add_window(TaskButton *button, Window win, const char *cl); -- 2.11.0 ------------------------------------------------------------------------------ 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