Commit 21d04729 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson
Browse files

Add TASKLIST_GLADEDIR, tasklist.schemas and tasklist.glade New files. Set

2002-01-13  Alexander Larsson  <alla@lysator.liu.se>
	* Makefile.am:
	Add TASKLIST_GLADEDIR, tasklist.schemas and tasklist.glade
	* tastklist.glade, tasklist.schemas:
	New files.
	* pager.c:
	Set up gconf before reading values to avoid tiny race.
	Handle workspaces being renamed.
	* tasklist.c:
	Add properties dialog.
parent f62f33be
2002-01-13 Alexander Larsson <alla@lysator.liu.se>
* Makefile.am:
Add TASKLIST_GLADEDIR, tasklist.schemas and tasklist.glade
* tastklist.glade, tasklist.schemas:
New files.
* pager.c:
Set up gconf before reading values to avoid tiny race.
Handle workspaces being renamed.
* tasklist.c:
Add properties dialog.
2002-01-13 Alexander Larsson <alla@lysator.liu.se>
* pager.c (num_workspaces_value_changed):
......
......@@ -8,10 +8,11 @@ INCLUDES = -I. -I$(srcdir) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS) \
-DPAGER_GLADEDIR=\""$(gladedir)"\" \
-DTASKLIST_GLADEDIR=\""$(gladedir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
gladedir = $(datadir)/gen_util
glade_DATA = pager.glade
glade_DATA = pager.glade tasklist.glade
libgen_util_applet_2_la_SOURCES = \
main.c \
......@@ -46,7 +47,7 @@ mailcheckbitmapsdir = $(datadir)/pixmaps/mailcheck
mailcheckbitmaps_DATA = $(MAILCHECK_BITMAPS)
schemadir = $(sysconfdir)/gconf/schemas
schema_DATA = mailcheck.schemas pager.schemas
schema_DATA = mailcheck.schemas pager.schemas tasklist.schemas
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_GenUtilApplet_Factory.server.in
......
2002-01-13 Alexander Larsson <alla@lysator.liu.se>
* Makefile.am:
Add TASKLIST_GLADEDIR, tasklist.schemas and tasklist.glade
* tastklist.glade, tasklist.schemas:
New files.
* pager.c:
Set up gconf before reading values to avoid tiny race.
Handle workspaces being renamed.
* tasklist.c:
Add properties dialog.
2002-01-13 Alexander Larsson <alla@lysator.liu.se>
* pager.c (num_workspaces_value_changed):
......
......@@ -8,10 +8,11 @@ INCLUDES = -I. -I$(srcdir) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS) \
-DPAGER_GLADEDIR=\""$(gladedir)"\" \
-DTASKLIST_GLADEDIR=\""$(gladedir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
gladedir = $(datadir)/gen_util
glade_DATA = pager.glade
glade_DATA = pager.glade tasklist.glade
libgen_util_applet_2_la_SOURCES = \
main.c \
......@@ -46,7 +47,7 @@ mailcheckbitmapsdir = $(datadir)/pixmaps/mailcheck
mailcheckbitmaps_DATA = $(MAILCHECK_BITMAPS)
schemadir = $(sysconfdir)/gconf/schemas
schema_DATA = mailcheck.schemas pager.schemas
schema_DATA = mailcheck.schemas pager.schemas tasklist.schemas
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_GenUtilApplet_Factory.server.in
......
......@@ -277,6 +277,8 @@ fill_pager_applet(PanelApplet *applet)
pager->applet = GTK_WIDGET (applet);
setup_gconf (pager);
error = NULL;
pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error);
if (error) {
......@@ -344,8 +346,6 @@ fill_pager_applet(PanelApplet *applet)
panel_applet_setup_menu (PANEL_APPLET (pager->applet), pager_menu_xml, pager_menu_verbs, pager);
setup_gconf (pager);
return TRUE;
}
......@@ -410,8 +410,6 @@ display_about_dialog (BonoboUIComponent *uic,
}
#define WID(s) glade_xml_get_widget (xml, s)
static void
display_workspace_names_toggled (GtkToggleButton *button,
PagerData *pager)
......@@ -465,9 +463,26 @@ update_workspaces_model (PagerData *pager)
}
static void
workspace_created_or_destroyed (WnckScreen *screen,
WnckWorkspace *space,
PagerData *pager)
workspace_renamed (WnckWorkspace *space,
PagerData *pager)
{
update_workspaces_model (pager);
}
static void
workspace_created (WnckScreen *screen,
WnckWorkspace *space,
PagerData *pager)
{
update_workspaces_model (pager);
g_signal_connect (G_OBJECT (space), "name_changed",
(GCallback) workspace_renamed, pager);
}
static void
workspace_destroyed (WnckScreen *screen,
WnckWorkspace *space,
PagerData *pager)
{
update_workspaces_model (pager);
}
......@@ -526,17 +541,17 @@ workspace_name_edited (GtkCellRendererText *cell_renderer_text,
g_slist_free (list);
}
#define WID(s) glade_xml_get_widget (xml, s)
static void
setup_dialog (GladeXML *xml,
PagerData *pager)
{
gboolean value;
GConfClient *client;
GtkTreeViewColumn *column;
GtkCellRenderer *cell;
int nr_ws, i;
client = gconf_client_get_default ();
pager->display_workspaces_toggle = WID ("workspace_name_toggle");
pager->all_workspaces_radio = WID ("all_workspaces_radio");
pager->current_only_radio = WID ("current_only_radio");
......@@ -585,9 +600,9 @@ setup_dialog (GladeXML *xml,
(GCallback) num_workspaces_value_changed, pager);
g_signal_connect_swapped (pager->screen, "workspace_created",
(GCallback) workspace_created_or_destroyed, pager);
(GCallback) workspace_created, pager);
g_signal_connect_swapped (pager->screen, "workspace_destroyed",
(GCallback) workspace_created_or_destroyed, pager);
(GCallback) workspace_destroyed, pager);
pager->workspaces_store = gtk_list_store_new (1, G_TYPE_STRING, NULL);
update_workspaces_model (pager);
......@@ -600,6 +615,12 @@ setup_dialog (GladeXML *xml,
gtk_tree_view_append_column (GTK_TREE_VIEW (pager->workspaces_tree), column);
g_signal_connect (cell, "edited",
(GCallback) workspace_name_edited, pager);
nr_ws = wnck_screen_get_workspace_count (pager->screen);
for (i = 0; i < nr_ws; i++) {
g_signal_connect (G_OBJECT (wnck_workspace_get (i)), "name_changed",
(GCallback) workspace_renamed, pager);
}
}
static void
......
......@@ -10,12 +10,15 @@
#define WNCK_I_KNOW_THIS_IS_UNSTABLE 1
#include <panel-applet.h>
#include <panel-applet-gconf.h>
#include <gtk/gtk.h>
#include <libbonobo.h>
#include <libgnome/libgnome.h>
#include <libgnomeui/libgnomeui.h>
#include <glade/glade-xml.h>
#include <libwnck/libwnck.h>
#include <gconf/gconf-client.h>
#include "tasklist.h"
......@@ -25,9 +28,21 @@ typedef struct {
GtkWidget *tasklist;
WnckScreen *screen;
gboolean include_all_workspaces;
gboolean enable_grouping;
gboolean move_unminimized_windows;
GtkOrientation orientation;
int size;
/* Properties: */
GtkWidget *properties_dialog;
GtkWidget *show_current_radio;
GtkWidget *show_all_radio;
GtkWidget *group_windows_toggle;
GtkWidget *move_minimized_radio;
GtkWidget *change_workspace_radio;
} TasklistData;
static void display_properties_dialog (BonoboUIComponent *uic,
......@@ -51,6 +66,12 @@ tasklist_update (TasklistData *tasklist)
gtk_widget_set_size_request (GTK_WIDGET (tasklist->tasklist),
tasklist->size, -1);
}
wnck_tasklist_set_allow_grouping (WNCK_TASKLIST (tasklist->tasklist),
tasklist->enable_grouping);
wnck_tasklist_set_include_all_workspaces (WNCK_TASKLIST (tasklist->tasklist),
tasklist->include_all_workspaces);
/* TODO: Set move_unminimized_windows */
}
......@@ -139,16 +160,176 @@ static const char tasklist_menu_xml [] =
" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
"</popup>\n";
static void
tasklist_properties_update_content_radio (TasklistData *tasklist)
{
GtkWidget *button;
if (tasklist->show_current_radio == NULL)
return;
if (tasklist->include_all_workspaces) {
button = tasklist->show_all_radio;
} else {
button = tasklist->show_current_radio;
}
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
static void
display_all_workspaces_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
TasklistData *tasklist)
{
gboolean value = FALSE; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_BOOL) {
value = gconf_value_get_bool (entry->value);
}
tasklist->include_all_workspaces = (value != 0);
tasklist_update (tasklist);
tasklist_properties_update_content_radio (tasklist);
}
static void
group_windows_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
TasklistData *tasklist)
{
gboolean value = FALSE; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_BOOL) {
value = gconf_value_get_bool (entry->value);
}
tasklist->enable_grouping = (value != 0);
tasklist_update (tasklist);
if (tasklist->group_windows_toggle &&
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tasklist->group_windows_toggle)) != tasklist->enable_grouping) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tasklist->group_windows_toggle),
tasklist->enable_grouping);
}
}
static void
tasklist_update_unminimization_radio (TasklistData *tasklist)
{
GtkWidget *button;
if (tasklist->move_minimized_radio == NULL)
return;
if (tasklist->move_unminimized_windows) {
button = tasklist->move_minimized_radio;
} else {
button = tasklist->change_workspace_radio;
}
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
}
static void
move_unminimized_windows_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
TasklistData *tasklist)
{
gboolean value = FALSE; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_BOOL) {
value = gconf_value_get_bool (entry->value);
}
tasklist->move_unminimized_windows = (value != 0);
tasklist_update (tasklist);
tasklist_update_unminimization_radio (tasklist);
}
static void
setup_gconf (TasklistData *tasklist)
{
GConfClient *client;
char *key;
client = gconf_client_get_default ();
key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
"display_all_workspaces");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)display_all_workspaces_changed,
tasklist,
NULL, NULL);
g_free (key);
key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
"group_windows");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)group_windows_changed,
tasklist,
NULL, NULL);
g_free (key);
key = panel_applet_gconf_get_full_key (PANEL_APPLET (tasklist->applet),
"move_unminimized_windows");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)move_unminimized_windows_changed,
tasklist,
NULL, NULL);
g_free (key);
}
gboolean
fill_tasklist_applet(PanelApplet *applet)
{
TasklistData *tasklist;
GError *error;
panel_applet_add_preferences (applet, "/schemas/apps/tasklist-applet/prefs", NULL);
tasklist = g_new0 (TasklistData, 1);
tasklist->applet = GTK_WIDGET (applet);
/* FIXME: We need to get the real initial panel data here */
setup_gconf (tasklist);
error = NULL;
tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
if (error) {
g_error_free (error);
tasklist->include_all_workspaces = FALSE; /* Default value */
}
error = NULL;
tasklist->enable_grouping = panel_applet_gconf_get_bool (applet, "group_windows", &error);
if (error) {
g_error_free (error);
tasklist->enable_grouping = TRUE; /* Default value */
}
error = NULL;
tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error);
if (error) {
g_error_free (error);
tasklist->move_unminimized_windows = TRUE; /* Default value */
}
/* FIXME: Would like to get the real initial panel data here */
tasklist->size = 48;
tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
......@@ -189,18 +370,12 @@ fill_tasklist_applet(PanelApplet *applet)
panel_applet_setup_menu (PANEL_APPLET (tasklist->applet), tasklist_menu_xml, tasklist_menu_verbs, tasklist);
setup_gconf (tasklist);
return TRUE;
}
static void
display_properties_dialog (BonoboUIComponent *uic,
TasklistData *tasklist,
const gchar *verbname)
{
/* FIXME: Implement this. */
}
static void
display_help_dialog (BonoboUIComponent *uic,
TasklistData *tasklist,
......@@ -259,3 +434,88 @@ display_about_dialog (BonoboUIComponent *uic,
gtk_widget_show (about);
}
static void
group_windows_toggled (GtkToggleButton *button,
TasklistData *tasklist)
{
panel_applet_gconf_set_bool (PANEL_APPLET (tasklist->applet),
"group_windows",
gtk_toggle_button_get_active (button),
NULL);
}
static void
move_minimized_toggled (GtkToggleButton *button,
TasklistData *tasklist)
{
panel_applet_gconf_set_bool (PANEL_APPLET (tasklist->applet),
"move_unminimized_windows",
gtk_toggle_button_get_active (button),
NULL);
}
static void
display_all_workspaces_toggled (GtkToggleButton *button,
TasklistData *tasklist)
{
panel_applet_gconf_set_bool (PANEL_APPLET (tasklist->applet),
"display_all_workspaces",
gtk_toggle_button_get_active (button),
NULL);
}
#define WID(s) glade_xml_get_widget (xml, s)
static void
setup_dialog (GladeXML *xml,
TasklistData *tasklist)
{
GConfClient *client;
client = gconf_client_get_default ();
tasklist->show_current_radio = WID ("show_current_radio");
tasklist->show_all_radio = WID ("show_all_radio");
tasklist->group_windows_toggle = WID ("group_windows_toggle");
tasklist->move_minimized_radio = WID ("move_minimized_radio");
tasklist->change_workspace_radio = WID ("change_workspace_radio");
/* Window grouping: */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tasklist->group_windows_toggle),
tasklist->enable_grouping);
g_signal_connect (G_OBJECT (tasklist->group_windows_toggle), "toggled",
(GCallback) group_windows_toggled, tasklist);
/* move window when unminimizing: */
tasklist_update_unminimization_radio (tasklist);
g_signal_connect (G_OBJECT (tasklist->move_minimized_radio), "toggled",
(GCallback) move_minimized_toggled, tasklist);
/* Tasklist content: */
tasklist_properties_update_content_radio (tasklist);
g_signal_connect (G_OBJECT (tasklist->show_all_radio), "toggled",
(GCallback) display_all_workspaces_toggled, tasklist);
g_signal_connect_swapped (WID ("done_button"), "pressed",
(GCallback) gtk_widget_hide, tasklist->properties_dialog);
}
static void
display_properties_dialog (BonoboUIComponent *uic,
TasklistData *tasklist,
const gchar *verbname)
{
if (tasklist->properties_dialog == NULL) {
GladeXML *xml;
xml = glade_xml_new (TASKLIST_GLADEDIR "/tasklist.glade", NULL, NULL);
tasklist->properties_dialog = glade_xml_get_widget (xml, "tasklist_properties_dialog");
setup_dialog (xml, tasklist);
g_object_unref (G_OBJECT (xml));
}
gtk_window_present (GTK_WINDOW (tasklist->properties_dialog));
}
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
<glade-interface>
<widget class="GtkDialog" id="tasklist_properties_dialog">
<property name="title" translatable="yes">Tasklist properties</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="modal">no</property>
<property name="allow_shrink">no</property>
<property name="allow_grow">yes</property>
<property name="has_separator">no</property>
<property name="visible">no</property>
<property name="window-position">GTK_WIN_POS_NONE</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="homogeneous">no</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="border_width">8</property>
<property name="homogeneous">yes</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="help_button">
<property name="can_focus">yes</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="label" translatable="yes">gtk-help</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="done_button">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">_Done</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
<property name="use_underline">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">yes</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="border_width">8</property>
<property name="homogeneous">no</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="homogeneous">no</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkFrame" id="frame2">
<property name="label" translatable="yes">Tasklist content</property>
<property name="label_xalign">0</property>
<property name="shadow">GTK_SHADOW_ETCHED_IN</property>
<property name="visible">yes</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="border_width">8</property>
<property name="homogeneous">no</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkRadioButton" id="show_current_radio">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Show windows from _current workspaces</property>
<property name="active">no</property>
<property name="draw_indicator">yes</property>
<property name="use_underline">yes</property>