stylus.c File Reference

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <libergtk/ergtk.h>
#include "i18n.h"
#include "log.h"
#include "ipc.h"
#include "settings.h"
#include "settings_utils.h"
#include "settings_style.h"
#include "stylus.h"
Include dependency graph for stylus.c:

Go to the source code of this file.

Functions

static GtkWidget * create_stylus_widgets (GtkBox *parent)
static gboolean on_calibrate_button_clicked (GtkWidget *widget, gpointer data)
static void init_widgets_with_settings (void)
static void on_listview_row_activated (GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
static void on_listview_navigate_cursor (erGtkListView *er_listview, erGtkListViewKeyPress keycode, gpointer user_data)
static gboolean on_focus_in (GtkWidget *widget, gpointer data)
static gboolean on_focus_out (GtkWidget *widget, gpointer data)
GtkWidget * create_stylus_window (GtkWidget *parent)
void load_stylus_settings ()
void save_stylus_settings ()

Variables

static GtkWidget * g_calibrate_button = NULL

Function Documentation

static GtkWidget * create_stylus_widgets ( GtkBox *  parent  )  [static]

Definition at line 200 of file stylus.c.

References description_create(), g_calibrate_button, ITEM_SPACING, on_calibrate_button_clicked(), and subject_create().

Referenced by create_stylus_window().

00201 {
00202      // Top level vbox.
00203     GtkWidget* top_level_vbox = gtk_vbox_new(FALSE, ITEM_SPACING);
00204     gtk_box_pack_start(parent, top_level_vbox, FALSE, FALSE, 0);
00205 
00206     // Subject
00207     GtkWidget* subject = subject_create();
00208     gtk_label_set_label(GTK_LABEL(subject),
00209         _("Calibration"));
00210     gtk_box_pack_start(GTK_BOX(top_level_vbox), subject, FALSE, FALSE, 0);
00211 
00212     // Description
00213     GtkWidget* desc = description_create();
00214     gtk_label_set_label(GTK_LABEL(desc),
00215         _("Calibrating the stylus improves accuracy, a particularly useful tool if you are left-handed."));
00216     gtk_box_pack_start(GTK_BOX(top_level_vbox), desc, FALSE, FALSE, 0);
00217     
00218     // create button box
00219     GtkWidget* button_box = gtk_hbutton_box_new();
00220     gtk_box_pack_start(GTK_BOX(top_level_vbox), button_box, FALSE, FALSE, 9);
00221     gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START);
00222     
00223     g_calibrate_button = gtk_button_new_with_label( _("Begin Calibration"));
00224     gtk_box_pack_start(GTK_BOX(button_box), g_calibrate_button, FALSE, FALSE, 0);
00225 
00226     // Add signal handler.
00227     g_signal_connect(G_OBJECT(g_calibrate_button),
00228             "clicked",
00229             G_CALLBACK(on_calibrate_button_clicked ),
00230             (gpointer) NULL );
00231 
00232     return top_level_vbox;
00233 }

Here is the call graph for this function:

Here is the caller graph for this function:

GtkWidget* create_stylus_window ( GtkWidget *  parent  ) 

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 91 of file stylus.c.

References create_settingsview(), create_stylus_widgets(), create_title(), init_widgets_with_settings(), on_focus_in(), on_focus_out(), on_listview_navigate_cursor(), on_listview_row_activated(), SMALL_SPACING, WINDOW_BORDER_PADDING, WINDOW_BOTTOM_PADDING, WINDOW_H_PADDING, and WINDOW_TOP_ALT_PADDING.

Referenced by create_concrete_win().

00092 {
00093     // create top window
00094     GtkWidget* top_window = parent;
00095     gtk_window_maximize(GTK_WINDOW(top_window));
00096     gtk_window_set_resizable(GTK_WINDOW(top_window), FALSE);
00097     gtk_container_set_border_width(GTK_CONTAINER(top_window),WINDOW_BORDER_PADDING  );
00098     gtk_window_set_modal(GTK_WINDOW(top_window), TRUE);
00099 
00100     // top level vbox (vboxtop)
00101     GtkWidget* vboxtop = gtk_vbox_new(FALSE, 0);
00102     gtk_container_add(GTK_CONTAINER(top_window), vboxtop);
00103 
00104     // add header container the title and subtitle of this settings page
00105     create_title(GTK_VBOX(vboxtop), _("Settings"), _("Stylus Calibration"));
00106     
00107     // add the back/exit bar below the title 
00108     GtkWidget* view = create_settingsview();
00109     gtk_box_pack_start(GTK_BOX(vboxtop), view, FALSE, FALSE,0 ); 
00110     g_signal_connect(view, "row-activated", G_CALLBACK(on_listview_row_activated), NULL ) ;
00111     g_signal_connect(view, "navigate-cursor", G_CALLBACK(on_listview_navigate_cursor), NULL ) ;
00112     g_signal_connect(view, "focus-in-event", G_CALLBACK(on_focus_in), NULL );
00113     g_signal_connect(view, "focus-out-event", G_CALLBACK(on_focus_out), NULL );
00114 
00115     // add an alignment below the exit bar
00116     GtkWidget* alignment = gtk_alignment_new(0, 0, 1.0, 0.0);
00117     gtk_container_add(GTK_CONTAINER(vboxtop), alignment);
00118 
00119     // introdude a frame in the alignment
00120     GtkWidget* frame = gtk_frame_new(NULL);
00121     gtk_widget_set_name(frame, "irex-margins-frame");
00122     gtk_container_add(GTK_CONTAINER(alignment), frame);
00123     gtk_container_set_border_width(GTK_CONTAINER(frame), 3);
00124 
00125     // alignment in frame 
00126     GtkWidget* alignment2 = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
00127     gtk_container_add(GTK_CONTAINER(frame), alignment2);
00128     gtk_alignment_set_padding(GTK_ALIGNMENT(alignment2),
00129                               WINDOW_TOP_ALT_PADDING,
00130                               WINDOW_BOTTOM_PADDING,
00131                               WINDOW_H_PADDING,
00132                               WINDOW_H_PADDING);
00133    
00134     // vbox in alignment2
00135     GtkWidget* innervbox = gtk_vbox_new(FALSE, SMALL_SPACING);
00136     gtk_container_add(GTK_CONTAINER(alignment2), innervbox);
00137     
00138     // The margin settings section.
00139     create_stylus_widgets(GTK_BOX(innervbox));
00140 
00141     // Update widget with current settings.
00142     init_widgets_with_settings();
00143 
00144     gtk_widget_grab_focus(view);
00145 
00146     gtk_widget_show_all(top_window);
00147     return top_window;
00148 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_widgets_with_settings ( void   )  [static]

Definition at line 250 of file stylus.c.

Referenced by create_stylus_window().

00251 {
00252     return;
00253 }

Here is the caller graph for this function:

void load_stylus_settings (  ) 

Definition at line 151 of file stylus.c.

References LOGPRINTF.

Referenced by create_concrete_win().

00152 {
00153     LOGPRINTF("Loading stylus settings\n");
00154 }

Here is the caller graph for this function:

static gboolean on_calibrate_button_clicked ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 235 of file stylus.c.

References ipc_menu_popup(), and LOGPRINTF.

Referenced by create_stylus_widgets().

00236 {
00237 
00238     LOGPRINTF("entry");
00239 
00240     ipc_menu_popup("block");
00241 
00242     // Call stylus calibration program.
00243     system("/usr/bin/gtktscal");
00244 
00245     ipc_menu_popup("unblock");
00246 
00247     return FALSE;
00248 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_focus_in ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 255 of file stylus.c.

References ERGTK_LIST_VIEW, and ergtk_list_view_set_cursor().

Referenced by create_stylus_window().

00256 {
00257     g_assert(widget != NULL ) ;
00258     ergtk_list_view_set_cursor( ERGTK_LIST_VIEW(widget), 0); // row = 0;
00259     return FALSE;
00260 }

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_focus_out ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 262 of file stylus.c.

Referenced by create_stylus_window().

00263 {
00264     g_assert(widget != NULL ) ;
00265     GtkTreeSelection* my_selection = gtk_tree_view_get_selection((GtkTreeView*) widget);
00266     g_assert( my_selection != NULL ) ;
00267     gtk_tree_selection_unselect_all(my_selection);
00268     return FALSE;
00269 }

Here is the caller graph for this function:

static void on_listview_navigate_cursor ( erGtkListView er_listview,
erGtkListViewKeyPress  keycode,
gpointer  user_data 
) [static]

Definition at line 177 of file stylus.c.

References ERGTK_LIST_VIEW_PRESS_LONG_DOWN, ERGTK_LIST_VIEW_PRESS_SHORT_DOWN, g_calibrate_button, and LOGPRINTF.

Referenced by create_stylus_window().

00180 {
00181     GtkTreeSelection* my_selection = gtk_tree_view_get_selection((GtkTreeView*) er_listview);
00182     g_assert( my_selection != NULL ) ;
00183 
00184     // determine new cursor position
00185     switch (keycode)
00186     {
00187         case ERGTK_LIST_VIEW_PRESS_SHORT_DOWN:
00188         case ERGTK_LIST_VIEW_PRESS_LONG_DOWN:
00189             gtk_widget_grab_focus(GTK_WIDGET(g_calibrate_button));
00190             gtk_tree_selection_unselect_all(my_selection);
00191             break;
00192         default:
00193             LOGPRINTF("illegal erGtkListViewKeyPress [%d]", keycode);
00194             ;  // ignore
00195             break;
00196     }
00197 
00198 }

Here is the caller graph for this function:

static void on_listview_row_activated ( GtkTreeView *  view,
GtkTreePath *  path,
GtkTreeViewColumn *  column,
gpointer  user_data 
) [static]

Definition at line 168 of file stylus.c.

References main_quit().

Referenced by create_stylus_window().

00172 {
00173     main_quit();
00174     return;
00175 }

Here is the call graph for this function:

Here is the caller graph for this function:

void save_stylus_settings (  ) 

Definition at line 157 of file stylus.c.

References LOGPRINTF.

00158 {
00159     LOGPRINTF("Saving stylus settings, done.\n");
00160 
00161 }


Variable Documentation

GtkWidget* g_calibrate_button = NULL [static]

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 65 of file stylus.c.

Referenced by create_stylus_widgets(), and on_listview_navigate_cursor().

Generated by  doxygen 1.6.2-20100208