pageBar/src/main.c File Reference

#include <config.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include <liberdm/display.h>
#include <liberipc/eripc.h>
#include <liberipc/eripcpagebar.h>
#include "erbusy.h"
#include "gtkPagebar.h"

Go to the source code of this file.

Defines

#define SERVER_BUFFER_SIZE   1024

Functions

static void on_destroy (GtkWidget *widget, gpointer data)
void pagebarMsgRxd (gpointer data, gint source_fd, GdkInputCondition condition)
static int installIpcServer ()
int main (int argc, char *argv[])

Variables

static GtkWidget * thePagebar
erServerChannel_t theServerChannel


Define Documentation

#define SERVER_BUFFER_SIZE   1024

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

Definition at line 32 of file main.c.


Function Documentation

static int installIpcServer (  )  [static]

Definition at line 136 of file main.c.

00137 {
00138     int     ret;
00139     int     fd = -1;
00140 
00141     ret = erIpcOpenServerChannel(ER_PAGEBAR_CHANNEL, &theServerChannel);
00142 
00143     if (ret != (-1))
00144     {
00145         fd = erIpcGetServerFd(theServerChannel);
00146 
00147         // gtk specific mechanism to monitor input file descriptor.
00148         ret = gdk_input_add(fd, GDK_INPUT_READ, pagebarMsgRxd, (gpointer) theServerChannel);
00149         return TRUE;
00150     }
00151     else
00152     {
00153         fprintf(stderr, "Could not open server channel\n");
00154         return FALSE;
00155     }
00156 }

Here is the call graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 158 of file main.c.

00159 {
00160     GtkWidget *window;
00161     GtkWidget *fixedContainer;
00162 
00163     int num_pages = 30;
00164     int selected_page = 15;
00165 
00166     if ( argc == 3 )
00167     {
00168         num_pages = atoi(argv[1]);
00169         selected_page = atoi(argv[2]);
00170     }
00171 
00172     /* init threads */
00173     g_thread_init(NULL);
00174     gdk_threads_init();
00175     gdk_threads_enter();
00176 
00177     // open the RC file associate with this program
00178     //    gtk_rc_parse(DATA_DIR "/contentLister.rc");
00179     //    CL_LOGPRINTF("rc file %s", DATA_DIR "/contentLister.rc");
00180 
00181     gtk_init(&argc, &argv);
00182 
00183     // create the main, top level, window 
00184     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00185 
00186     gtk_window_set_title(GTK_WINDOW(window), PACKAGE " " VERSION);
00187     gtk_window_set_accept_focus(GTK_WINDOW(window), FALSE);  // window cannot get focus, as this causes trouble with keyboard
00188     gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DOCK); // Tell WM to dock this window
00189     gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_NONE); 
00190     gtk_container_set_border_width(GTK_CONTAINER(window), 0);
00191     gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
00192 
00193     gtk_window_set_modal(GTK_WINDOW(window), TRUE);
00194     gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
00195 
00196     fixedContainer = gtk_fixed_new();
00197 
00198     thePagebar = gtk_pagebar_new();
00199 
00200     if (thePagebar)
00201     {
00202         // Connect the destroy event of the window with our on_destroy function
00203         // When the window is about to be destroyed we get a notificaton and
00204         // stop the main GTK loop
00205         g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), thePagebar);
00206     }
00207 
00208 
00209     // gtk_container_add(GTK_CONTAINER(fixedContainer), thePagebar);
00210     gtk_fixed_put(GTK_FIXED(fixedContainer), thePagebar, 0, 0);
00211     gtk_container_add(GTK_CONTAINER(window), fixedContainer);
00212     gtk_pagebar_draw(GTK_PAGEBAR(thePagebar));
00213     {
00214         GtkPagebar* pagebar = GTK_PAGEBAR(thePagebar);
00215         GtkWidget* entry = gtk_entry_new_with_max_length(4);
00216         gtk_widget_set_size_request(GTK_WIDGET(entry), pagebar->cpiWidth-6, 24);
00217         gtk_fixed_put( GTK_FIXED(fixedContainer),
00218             entry,
00219             pagebar->barXPos + (pagebar->barWidth  - pagebar->cpiWidth) / 2 + 3,
00220             pagebar->barYPos + (pagebar->barHeight - pagebar->cpiWidth) / 2 + 18 );
00221         pagebar->pageEntry = entry;
00222     }
00223 
00224     // gtk_pagebar_selectpage(GTK_PAGEBAR(pagebar), selected_page);
00225 
00226     // associate control callback -- IPC calls have to be connected using this...
00227     // g_signal_connect(G_OBJECT(pagebar), "pagebar_page_selected", G_CALLBACK(ctrl_pagebar_clicked_event), pagebar);
00228 
00229     installIpcServer();
00230     erbusy_init();
00231 
00232     gtk_widget_show(thePagebar);
00233     gtk_widget_show(fixedContainer);
00234     gtk_widget_show(window);
00235 
00236     gtk_main();
00237     gdk_threads_leave();
00238 
00239     return 0;
00240 }

Here is the call graph for this function:

static void on_destroy ( GtkWidget *  widget,
gpointer  data 
) [static]

Definition at line 37 of file main.c.

00038 {
00039     // Do stuff before quitting... 
00040     // Noting here yet.
00041 
00042     gtk_main_quit();
00043 }

void pagebarMsgRxd ( gpointer  data,
gint  source_fd,
GdkInputCondition  condition 
)

Definition at line 45 of file main.c.

00046 {
00047     char    szBuffer[SERVER_BUFFER_SIZE];
00048     int     nBuf = SERVER_BUFFER_SIZE;
00049     erIpcCmd_t command;
00050     GtkPagebar* pagebar = GTK_PAGEBAR(thePagebar);    
00051 
00052     erIpcGetMessage((erServerChannel_t) data, szBuffer, &nBuf);
00053     //printf("Received %s\n", szBuffer);
00054 
00055     if (pbParseCommand(szBuffer, &command) >= 0)
00056     {
00057         switch (command.cc)
00058         {
00059         case ccPbSetPageCount:
00060             pagebar->pagecount = atoi(command.arg[1]);
00061             break;
00062         case ccPbSetCurrentPage:
00063             // currentPage cannot be less than 1
00064             pagebar->currentPage = (atoi(command.arg[1]) < 1) ? 1 : atoi(command.arg[1]);
00065             //following line is added by Jian for bug:347
00066             pagebar->lastPage=pagebar->currentPage;
00067             break;
00068         case ccPbSetCurrentPageOffset:
00069             pagebar->currentPageOffset = atoi(command.arg[1]);
00070             break;
00071         case ccPbSetZoomMode:
00072             pagebar->zoomMode = atoi(command.arg[1]);
00073             break;
00074         case ccPbSetDrawAreaOrientation:
00075             /* Todo */
00076             pagebar->orientation = atoi(command.arg[1]);
00077             break;
00078         case ccPbSetDrawAreaHOrigin:
00079             pagebar->drawAreaXPos = atoi(command.arg[1]);
00080             break;
00081         case ccPbSetDrawAreaVOrigin:
00082             pagebar->drawAreaYPos = atoi(command.arg[1]);
00083             break;
00084         case ccPbSetDrawAreaHSize:
00085             pagebar->drawAreaWidth = atoi(command.arg[1]);
00086             break;
00087         case ccPbSetDrawAreaVSize:
00088             pagebar->drawAreaHeight = atoi(command.arg[1]);
00089             break;
00090         case ccPbSetBarFontType:
00091             pagebar->barFontType = atoi(command.arg[1]);
00092             break;
00093         case ccPbSetBarFontHeight:
00094             pagebar->barFontHeight = atoi(command.arg[1]);
00095             break;
00096         case ccPbAddBookmark:
00097             addBookmark(pagebar, atoi(command.arg[1]));
00098             break;
00099         case ccPbRemoveBookmark:
00100             removeBookmark(pagebar, atoi(command.arg[1]));
00101             break;
00102         case ccPbSetBookmarkMax:
00103             pagebar->bookmarkMaxValue = atoi(command.arg[1]);
00104             break;
00105         case ccPbAddNote:
00106             addNote(pagebar, atoi(command.arg[1]));
00107             break;
00108         case ccPbRemoveNote:
00109             removeNote(pagebar, atoi(command.arg[1]));
00110             break;
00111         case ccPbSetNotesMax:
00112             pagebar->notesMaxValue = atoi(command.arg[1]);
00113             break;
00114         case ccPbReset:
00115             pagebar->currentApp = atoi(command.arg[0]);
00116             //                    printf("Current app = %d\n", pagebar->currentApp);
00117             pagebar_reset_values(pagebar);
00118             break;
00119         case ccPbShow:
00120             pagebar->show = atoi(command.arg[1]);
00121             break;
00122         case ccPbRedraw:
00123             gtk_pagebar_draw(pagebar);
00124             break;
00125         case ccPbSynchronise:
00126             // printf("\nOn receive pbSynchronise message from application\n");
00127             pagebar_reportSync(pagebar);
00128             break;            
00129         default:
00130             printf("UNKNOWN COMMAND %d\n", command.cc);
00131             break;
00132         }
00133     }
00134 }

Here is the call graph for this function:


Variable Documentation

GtkWidget* thePagebar [static]

Definition at line 34 of file main.c.

Definition at line 35 of file main.c.


Generated on Sun Dec 14 17:15:19 2008 by  doxygen 1.5.6