make more of the ui work

This commit is contained in:
Richard Hughes 2007-08-15 02:03:18 +01:00
parent 7bb9f24c20
commit ed238e390a
3 changed files with 301 additions and 125 deletions

View File

@ -35,7 +35,7 @@ INCLUDES = \
bin_PROGRAMS = \
pkcon \
pkmon \
pk-application
pk-application \
pk-update-icon \
$(NULL)
@ -114,6 +114,14 @@ pk_application_SOURCES = \
pk-debug.h \
pk-application.c \
pk-application.h \
pk-marshal.c \
pk-marshal.h \
pk-task-utils.h \
pk-task-utils.c \
pk-task-common.c \
pk-task-common.h \
pk-task-client.c \
pk-task-client.h \
$(NULL)
pk_application_LDADD = \

View File

@ -31,6 +31,7 @@
#include "pk-application.h"
#include "pk-debug.h"
#include "pk-task-client.h"
static void pk_application_class_init (PkApplicationClass *klass);
static void pk_application_init (PkApplication *application);
@ -41,6 +42,7 @@ static void pk_application_finalize (GObject *object);
struct PkApplicationPrivate
{
GladeXML *glade_xml;
GtkListStore *store;
};
enum {
@ -49,6 +51,14 @@ enum {
LAST_SIGNAL
};
enum
{
COLUMN_INSTALLED,
COLUMN_PACKAGE,
COLUMN_DESCRIPTION,
NUM_COLUMNS
};
static guint signals [LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (PkApplication, pk_application, G_TYPE_OBJECT)
@ -110,16 +120,47 @@ pk_application_close_cb (GtkWidget *widget,
g_signal_emit (application, signals [ACTION_CLOSE], 0);
}
/**
* pk_console_package_cb:
**/
static void
pk_console_package_cb (PkTaskClient *tclient, const gchar *package, const gchar *summary, PkApplication *application)
{
GtkTreeIter iter;
g_debug ("package = %s:%s", package, summary);
gtk_list_store_append (application->priv->store, &iter);
gtk_list_store_set (application->priv->store, &iter,
COLUMN_INSTALLED, TRUE,
COLUMN_PACKAGE, package,
COLUMN_DESCRIPTION, summary,
-1);
}
/**
* pk_application_find_cb:
* @widget: The GtkWidget object
* @graph: This graph class instance
**/
static void
pk_application_find_cb (GtkWidget *widget,
pk_application_find_cb (GtkWidget *button_widget,
PkApplication *application)
{
g_error ("find");
GtkWidget *widget;
const gchar *package;
PkTaskClient *tclient;
widget = glade_xml_get_widget (application->priv->glade_xml, "entry_text");
package = gtk_entry_get_text (GTK_ENTRY (widget));
/* clear existing list */
gtk_list_store_clear (application->priv->store);
g_debug ("find %s", package);
tclient = pk_task_client_new ();
g_signal_connect (tclient, "package",
G_CALLBACK (pk_console_package_cb), application);
pk_task_client_find_packages (tclient, package);
}
/**
@ -137,44 +178,76 @@ pk_application_delete_event_cb (GtkWidget *widget,
return FALSE;
}
/**
* pk_graph_widget_custom_handler:
* @xml: The glade file we are reading.
* @func_name: The function name to create the object
*
* Handler for libglade to provide interface with a pointer
*
* Return value: The custom widget.
**/
static GtkWidget *
pk_graph_widget_custom_handler (GladeXML *xml,
gchar *func_name, gchar *name,
gchar *string1, gchar *string2,
gint int1, gint int2,
gpointer user_data)
static gboolean
pk_application_text_changed_cb (GtkEntry *entry, GdkEventKey *event, PkApplication *application)
{
GtkWidget *widget = NULL;
if (strcmp ("pk_graph_new", func_name) == 0) {
widget = NULL;
return widget;
GtkWidget *widget;
const gchar *package;
widget = glade_xml_get_widget (application->priv->glade_xml, "entry_text");
package = gtk_entry_get_text (GTK_ENTRY (widget));
widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
if (package == NULL || strlen (package) == 0) {
gtk_widget_set_sensitive (widget, FALSE);
} else {
gtk_widget_set_sensitive (widget, TRUE);
}
return NULL;
return FALSE;
}
#if 0
/**
* pk_application_checkbox_events_cb:
* @widget: The GtkWidget object
**/
static void
pk_application_checkbox_events_cb (GtkWidget *widget,
PkApplication *application)
pk_misc_installed_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
{
gboolean checked;
checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
pk_debug ("Events enable %i", checked);
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
gboolean installed;
/* get toggled iter */
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, COLUMN_INSTALLED, &installed, -1);
/* do something with the value */
installed ^= 1;
/* set new value */
gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_INSTALLED, installed, -1);
/* clean up */
gtk_tree_path_free (path);
}
#endif
static void
pk_misc_add_columns (GtkTreeView *treeview)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
/* column for installed toggles */
renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect (renderer, "toggled", G_CALLBACK (pk_misc_installed_toggled), model);
column = gtk_tree_view_column_new_with_attributes ("Installed", renderer,
"active", COLUMN_INSTALLED, NULL);
gtk_tree_view_append_column (treeview, column);
/* column for severities */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Name", renderer,
"text", COLUMN_PACKAGE, NULL);
gtk_tree_view_column_set_sort_column_id (column, COLUMN_PACKAGE);
gtk_tree_view_append_column (treeview, column);
/* column for description */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Description", renderer,
"text", COLUMN_DESCRIPTION, NULL);
gtk_tree_view_column_set_sort_column_id (column, COLUMN_DESCRIPTION);
gtk_tree_view_append_column (treeview, column);
}
/**
* pk_application_init:
@ -188,31 +261,45 @@ pk_application_init (PkApplication *application)
application->priv = PK_APPLICATION_GET_PRIVATE (application);
glade_set_custom_handler (pk_graph_widget_custom_handler, application);
application->priv->glade_xml = glade_xml_new (PK_DATA "/pk-application.glade", NULL, NULL);
main_window = glade_xml_get_widget (application->priv->glade_xml, "window_manager");
/* Hide window first so that the dialogue resizes itself without redrawing */
gtk_widget_hide (main_window);
// gtk_window_set_icon_name (GTK_WINDOW (main_window), PK_STOCK_APP_ICON);
gtk_window_set_icon_name (GTK_WINDOW (main_window), "software-update-available");
/* Get the main window quit */
g_signal_connect (main_window, "delete_event",
G_CALLBACK (pk_application_delete_event_cb), application);
widget = glade_xml_get_widget (application->priv->glade_xml, "button_close");
widget = glade_xml_get_widget (application->priv->glade_xml, "toolbutton_close");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_application_close_cb), application);
widget = glade_xml_get_widget (application->priv->glade_xml, "button_help");
widget = glade_xml_get_widget (application->priv->glade_xml, "toolbutton_help");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_application_help_cb), application);
widget = glade_xml_get_widget (application->priv->glade_xml, "toolbutton_install");
gtk_widget_set_sensitive (widget, TRUE);
widget = glade_xml_get_widget (application->priv->glade_xml, "toolbutton_remove");
gtk_widget_set_sensitive (widget, FALSE);
widget = glade_xml_get_widget (application->priv->glade_xml, "toolbutton_deps");
gtk_widget_set_sensitive (widget, FALSE);
widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
g_signal_connect (widget, "clicked",
G_CALLBACK (pk_application_find_cb), application);
widget = glade_xml_get_widget (application->priv->glade_xml, "entry_text");
g_signal_connect (widget, "key-press-event",
G_CALLBACK (pk_application_text_changed_cb), application);
g_signal_connect (widget, "key-release-event",
G_CALLBACK (pk_application_text_changed_cb), application);
widget = glade_xml_get_widget (application->priv->glade_xml, "button_find");
gtk_widget_set_sensitive (widget, FALSE);
// widget = glade_xml_get_widget (application->priv->glade_xml, "custom_graph");
// gtk_widget_set_size_request (widget, 600, 300);
@ -220,16 +307,22 @@ pk_application_init (PkApplication *application)
gtk_widget_hide (GTK_WIDGET (widget));
gtk_widget_show (GTK_WIDGET (widget));
// widget = glade_xml_get_widget (application->priv->glade_xml, "combobox_type");
// pk_application_populate_graph_types (application, widget);
// widget = glade_xml_get_widget (application->priv->glade_xml, "checkbutton_events");
// pk_conf_get_bool (application->priv->conf, PK_CONF_STATS_SHOW_EVENTS, &checked);
// gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), checked);
// g_signal_connect (widget, "clicked",
// G_CALLBACK (pk_application_checkbox_events_cb), application);
gtk_widget_set_size_request (main_window, 700, 300);
gtk_widget_show (main_window);
/* create list store */
application->priv->store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_BOOLEAN,
G_TYPE_STRING,
G_TYPE_STRING);
/* create tree view */
widget = glade_xml_get_widget (application->priv->glade_xml, "treeview_packages");
gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
GTK_TREE_MODEL (application->priv->store));
/* add columns to the tree view */
pk_misc_add_columns (GTK_TREE_VIEW (widget));
}
/**
@ -245,6 +338,9 @@ pk_application_finalize (GObject *object)
application = PK_APPLICATION (object);
application->priv = PK_APPLICATION_GET_PRIVATE (application);
g_object_unref (application->priv->store);
G_OBJECT_CLASS (pk_application_parent_class)->finalize (object);
}

View File

@ -8,13 +8,13 @@
<property name="visible">True</property>
<property name="title" translatable="yes">PackageKit Manager</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">True</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon_name">gtk-info</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
@ -22,138 +22,210 @@
<property name="urgency_hint">False</property>
<child>
<widget class="GtkVBox" id="vbox_rows">
<property name="border_width">15</property>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox_header">
<widget class="GtkToolbar" id="toolbar2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<property name="tooltips">True</property>
<property name="show_arrow">True</property>
<child>
<widget class="GtkLabel" id="label_suggest">
<widget class="GtkToolButton" id="toolbutton_close">
<property name="visible">True</property>
<property name="label" translatable="yes">Package:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</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="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
<property name="stock_id">gtk-close</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_text">
<widget class="GtkToolButton" id="toolbutton_install">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">False</property>
<property name="label" translatable="yes">Install</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-floppy</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_find">
<widget class="GtkToolButton" id="toolbutton_remove">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-find</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="label" translatable="yes">_Remove</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-dialog-error</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_help">
<widget class="GtkToolButton" id="toolbutton_deps">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="label" translatable="yes">Dependancies</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-jump-to</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_close">
<widget class="GtkToolButton" id="toolbutton_help">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="stock_id">gtk-help</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow_packages">
<widget class="GtkVBox" id="vbox_rows">
<property name="border_width">15</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkTreeView" id="treeview_packages">
<widget class="GtkHBox" id="hbox_header">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">10</property>
<child>
<widget class="GtkLabel" id="label_suggest">
<property name="visible">True</property>
<property name="label" translatable="yes">Package:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</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="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_find">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-find</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow_packages">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_packages">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>