Commit 9a2076aa authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson
Browse files

Add gladefile and schemas file for pager.

2002-01-12  Alexander Larsson  <alla@lysator.liu.se>

	* Makefile.am:
	Add gladefile and schemas file for pager.

	* pager.c:
	First cut at the properties dialog.

	* pager.glade:
	* pager.schemas:
	New files.
parent fc354e11
#SUBDIRS = help
INCLUDES = -I. -I$(srcdir) \
-I$(srcdir)/../../libpanel-applet \
-I$(top_builddir)/libpanel-applet \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) \
$(GNOME_INCLUDEDIR) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS)
INCLUDES = -I. -I$(srcdir) \
-I$(srcdir)/../../libpanel-applet \
-I$(top_builddir)/libpanel-applet \
-I$(includedir) \
$(GNOME_INCLUDEDIR) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS) \
-DPAGER_GLADEDIR=\""$(gladedir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
gladedir = $(datadir)/gen_util
glade_DATA = pager.glade
libgen_util_applet_2_la_SOURCES = \
main.c \
clock.c \
clock.h \
pager.c \
pager.h \
tasklist.c \
tasklist.h \
mailcheck.c \
mailcheck.h \
popcheck.c \
popcheck.h \
remote-helper.c \
remote-helper.h
main.c \
clock.c \
clock.h \
pager.c \
pager.h \
tasklist.c \
tasklist.h \
mailcheck.c \
mailcheck.h \
popcheck.c \
popcheck.h \
remote-helper.c \
remote-helper.h
libgen_util_applet_2_la_LIBADD = \
../../libpanel-applet/libpanel-applet-2.la \
$(WNCKLET_LIBS)
../../libpanel-applet/libpanel-applet-2.la \
$(WNCKLET_LIBS)
appletdir = $(libdir)
applet_LTLIBRARIES = libgen_util_applet-2.la
......@@ -38,15 +42,11 @@ PRINTER_BITMAPS = print.xpm
MAILCHECK_BITMAPS = email.png email-e.png tux-anim.png email-eclouds.png \
email-tiny.png eclouds.png
EXTRA_DIST = GNOME_GenUtilApplet_Factory.server.in.in \
$(PRINTER_BITMAPS) \
$(MAILCHECK_BITMAPS)
mailcheckbitmapsdir = $(datadir)/pixmaps/mailcheck
mailcheckbitmaps_DATA = $(MAILCHECK_BITMAPS)
schemadir = $(sysconfdir)/gconf/schemas
schema_DATA = mailcheck.schemas
schema_DATA = mailcheck.schemas pager.schemas
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_GenUtilApplet_Factory.server.in
......@@ -54,5 +54,16 @@ server_DATA = $(server_in_files:.server.in=.server)
@INTLTOOL_SERVER_RULE@
# don't do this if we are building in eg. rpm
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schema_DATA)
if test -z "$(DESTDIR)" ; then \
for p in $(schema_DATA) ; do \
GCONF_CONFIG_SOURCE=$(GCONF_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p ; \
done \
fi
EXTRA_DIST = GNOME_GenUtilApplet_Factory.server.in.in \
$(PRINTER_BITMAPS) \
$(MAILCHECK_BITMAPS) \
$(schema_DATA) \
$(glade_DATA)
#SUBDIRS = help
INCLUDES = -I. -I$(srcdir) \
-I$(srcdir)/../../libpanel-applet \
-I$(top_builddir)/libpanel-applet \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) \
$(GNOME_INCLUDEDIR) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS)
INCLUDES = -I. -I$(srcdir) \
-I$(srcdir)/../../libpanel-applet \
-I$(top_builddir)/libpanel-applet \
-I$(includedir) \
$(GNOME_INCLUDEDIR) \
$(WARN_CFLAGS) \
$(WNCKLET_CFLAGS) \
-DPAGER_GLADEDIR=\""$(gladedir)"\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"
gladedir = $(datadir)/gen_util
glade_DATA = pager.glade
libgen_util_applet_2_la_SOURCES = \
main.c \
clock.c \
clock.h \
pager.c \
pager.h \
tasklist.c \
tasklist.h \
mailcheck.c \
mailcheck.h \
popcheck.c \
popcheck.h \
remote-helper.c \
remote-helper.h
main.c \
clock.c \
clock.h \
pager.c \
pager.h \
tasklist.c \
tasklist.h \
mailcheck.c \
mailcheck.h \
popcheck.c \
popcheck.h \
remote-helper.c \
remote-helper.h
libgen_util_applet_2_la_LIBADD = \
../../libpanel-applet/libpanel-applet-2.la \
$(WNCKLET_LIBS)
../../libpanel-applet/libpanel-applet-2.la \
$(WNCKLET_LIBS)
appletdir = $(libdir)
applet_LTLIBRARIES = libgen_util_applet-2.la
......@@ -38,15 +42,11 @@ PRINTER_BITMAPS = print.xpm
MAILCHECK_BITMAPS = email.png email-e.png tux-anim.png email-eclouds.png \
email-tiny.png eclouds.png
EXTRA_DIST = GNOME_GenUtilApplet_Factory.server.in.in \
$(PRINTER_BITMAPS) \
$(MAILCHECK_BITMAPS)
mailcheckbitmapsdir = $(datadir)/pixmaps/mailcheck
mailcheckbitmaps_DATA = $(MAILCHECK_BITMAPS)
schemadir = $(sysconfdir)/gconf/schemas
schema_DATA = mailcheck.schemas
schema_DATA = mailcheck.schemas pager.schemas
serverdir = $(libdir)/bonobo/servers
server_in_files = GNOME_GenUtilApplet_Factory.server.in
......@@ -54,5 +54,16 @@ server_DATA = $(server_in_files:.server.in=.server)
@INTLTOOL_SERVER_RULE@
# don't do this if we are building in eg. rpm
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$(schema_DATA)
if test -z "$(DESTDIR)" ; then \
for p in $(schema_DATA) ; do \
GCONF_CONFIG_SOURCE=$(GCONF_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p ; \
done \
fi
EXTRA_DIST = GNOME_GenUtilApplet_Factory.server.in.in \
$(PRINTER_BITMAPS) \
$(MAILCHECK_BITMAPS) \
$(schema_DATA) \
$(glade_DATA)
......@@ -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 "pager.h"
......@@ -26,6 +29,13 @@ typedef struct {
GtkWidget *pager;
WnckScreen *screen;
/* Properties: */
GtkWidget *properties_dialog;
GtkWidget *display_workspaces_toggle;
GtkWidget *all_workspaces_radio;
GtkWidget *current_only_radio;
GtkWidget *num_rows_spin;
GtkOrientation orientation;
int n_rows;
......@@ -127,17 +137,65 @@ static const char pager_menu_xml [] =
" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
"</popup>\n";
static void
num_rows_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
PagerData *pager)
{
int n_rows = 2; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_INT) {
n_rows = gconf_value_get_int (entry->value);
}
pager->n_rows = n_rows;
pager_update (pager);
if (pager->num_rows_spin &&
gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (pager->num_rows_spin)) != n_rows)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pager->num_rows_spin), pager->n_rows);
}
static void
setup_gconf (PagerData *pager)
{
GConfClient *client;
char *key;
client = gconf_client_get_default ();
key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
"num_rows");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)num_rows_changed,
pager,
NULL, NULL);
g_free (key);
}
gboolean
fill_pager_applet(PanelApplet *applet)
{
PagerData *pager;
GError *error;
panel_applet_add_preferences (applet, "/schemas/apps/pager-applet/prefs", NULL);
pager = g_new0 (PagerData, 1);
pager->applet = GTK_WIDGET (applet);
/* FIXME: Default value, should be from gconf? */
pager->n_rows = 2;
error = NULL;
pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error);
if (error) {
g_error_free (error);
pager->n_rows = 2; /* Default value */
}
/* FIXME: We need to get the real initial panel data here */
pager->size = 48;
......@@ -179,19 +237,13 @@ fill_pager_applet(PanelApplet *applet)
pager);
panel_applet_setup_menu (PANEL_APPLET (pager->applet), pager_menu_xml, pager_menu_verbs, pager);
setup_gconf (pager);
return TRUE;
}
static void
display_properties_dialog (BonoboUIComponent *uic,
PagerData *pager,
const gchar *verbname)
{
/* FIXME: Implement this. Should only need n_rows */
}
static void
display_help_dialog (BonoboUIComponent *uic,
PagerData *pager,
......@@ -250,3 +302,183 @@ display_about_dialog (BonoboUIComponent *uic,
gtk_widget_show (about);
}
#define WID(s) glade_xml_get_widget (xml, s)
static void
display_workspace_names_toggled (GtkToggleButton *button,
PagerData *pager)
{
g_print ("display_workspace_names_toggled, widget state:%d\n", gtk_toggle_button_get_active (button));
panel_applet_gconf_set_bool (PANEL_APPLET (pager->applet),
"display_workspace_names",
gtk_toggle_button_get_active (button),
NULL);
}
static void
display_workspace_names_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
PagerData *pager)
{
gboolean value = FALSE; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_BOOL) {
value = gconf_value_get_bool (entry->value);
}
g_print ("display_workspace_names_changed, value=%d\n", value);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->display_workspaces_toggle),
value);
/* TODO: Actually change whether workspace names are shown or not */
}
static void
all_workspaces_toggled (GtkToggleButton *button,
PagerData *pager)
{
panel_applet_gconf_set_bool (PANEL_APPLET (pager->applet),
"display_all_workspaces",
gtk_toggle_button_get_active (button),
NULL);
}
static void
num_rows_value_changed (GtkSpinButton *button,
PagerData *pager)
{
panel_applet_gconf_set_int (PANEL_APPLET (pager->applet),
"num_rows",
gtk_spin_button_get_value_as_int (button),
NULL);
}
static void
all_workspaces_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
PagerData *pager)
{
gboolean value = TRUE; /* Default value */
if (entry->value != NULL &&
entry->value->type == GCONF_VALUE_BOOL) {
value = gconf_value_get_bool (entry->value);
}
g_print ("all_workspaces_changed, value=%d\n", value);
if (value) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->all_workspaces_radio), TRUE);
gtk_widget_set_sensitive (pager->num_rows_spin, TRUE);
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->current_only_radio), TRUE);
gtk_widget_set_sensitive (pager->num_rows_spin, FALSE);
}
/* TODO: Actually change whether ... */
}
static void
setup_dialog (GladeXML *xml,
PagerData *pager)
{
gchar *key;
gboolean value;
GError *error;
GConfClient *client;
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");
pager->num_rows_spin = WID ("num_rows_spin");
/* Display workspace names: */
g_signal_connect (G_OBJECT (pager->display_workspaces_toggle), "toggled",
(GCallback) display_workspace_names_toggled, pager);
key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
"display_workspace_names");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)display_workspace_names_changed,
pager,
NULL, NULL);
error = NULL;
value = gconf_client_get_bool (client, key, &error);
if (error) {
g_error_free (error);
value = FALSE; /* Default value */
}
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->display_workspaces_toggle),
value);
g_free (key);
/* Display all workspaces: */
g_signal_connect (G_OBJECT (pager->all_workspaces_radio), "toggled",
(GCallback) all_workspaces_toggled, pager);
key = panel_applet_gconf_get_full_key (PANEL_APPLET (pager->applet),
"display_all_workspaces");
gconf_client_notify_add(client, key,
(GConfClientNotifyFunc)all_workspaces_changed,
pager,
NULL, NULL);
error = NULL;
value = gconf_client_get_bool (client, key, &error);
if (error) {
g_error_free (error);
value = TRUE; /* Default value */
}
if (value) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->all_workspaces_radio), TRUE);
gtk_widget_set_sensitive (pager->num_rows_spin, TRUE);
} else {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pager->current_only_radio), TRUE);
gtk_widget_set_sensitive (pager->num_rows_spin, FALSE);
}
g_free (key);
/* Num rows: */
g_signal_connect (G_OBJECT (pager->num_rows_spin), "value_changed",
(GCallback) num_rows_value_changed, pager);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pager->num_rows_spin), pager->n_rows);
}
static void
display_properties_dialog (BonoboUIComponent *uic,
PagerData *pager,
const gchar *verbname)
{
if (pager->properties_dialog == NULL) {
GladeXML *xml;
xml = glade_xml_new (PAGER_GLADEDIR "/pager.glade", NULL, NULL);
pager->properties_dialog = glade_xml_get_widget (xml, "pager_properties_dialog");
setup_dialog (xml, pager);
g_object_unref (G_OBJECT (xml));
}
gtk_window_present (GTK_WINDOW (pager->properties_dialog));
/* FIXME: Implement this. Should only need n_rows */
}
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" >
<glade-interface>
<widget class="GtkDialog" id="pager_properties_dialog">
<property name="title" translatable="yes">Pager 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-vbox1">
<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_area1">
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="button1">
<property name="can_default">yes</property>
<property name="can_focus">yes</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>
</child>
<child>
<widget class="GtkButton" id="button3">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="label" translatable="yes">_Done</property>
<property name="visible">yes</property>
<property name="use_underline">yes</property>
</widget>
</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">yes</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkFrame" id="frame2">
<property name="label" translatable="yes">Pager</property>
<property name="label_xalign">0</property>
<property name="shadow">GTK_SHADOW_ETCHED_IN</property>
<property name="visible">yes</property>
<child>
<widget class="GtkTable" id="table1">
<property name="border_width">8</property>
<property name="homogeneous">no</property>
<property name="row_spacing">8</property>
<property name="column_spacing">8</property>
<property name="n-rows">4</property>
<property name="n-columns">2</property>
<property name="visible">yes</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="homogeneous">no</property>
<property name="spacing">4</property>
<property name="visible">yes</property>
<child>
<widget class="GtkSpinButton" id="num_rows_spin">
<property name="can_focus">yes</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">no</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="wrap">no</property>
<property name="snap_to_ticks">no</property>
<property name="visible">yes</property>
<property name="adjustment">1 1 100 1 10 10</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="label" translatable="yes">Rows</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">no</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">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="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_padding">0</property>
<property name="y_padding">0</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>