Beispiel #1
0
static void
updated_database_cb (gpointer data, gpointer user_data)
{
    FsearchApplicationWindow *win = (FsearchApplicationWindow *) user_data;
    g_assert (FSEARCH_WINDOW_IS_WINDOW (win));

    hide_overlays (win);
    update_statusbar (win, "");

    fsearch_application_window_update_search (win);

    gtk_spinner_stop (GTK_SPINNER (win->database_spinner));

    gtk_stack_set_visible_child (GTK_STACK (win->database_stack), win->database_box2);
    Database *db = fsearch_application_get_db (FSEARCH_APPLICATION_DEFAULT);
    uint32_t num_items = db_get_num_entries (db);
    gchar db_text[100] = "";
    snprintf (db_text, sizeof (db_text), _("%'d Items"), num_items);
    gtk_label_set_text (GTK_LABEL (win->database_label), db_text);


    time_t timestamp = db_get_timestamp (db);
    strftime (db_text, sizeof(db_text),
             "Last Updated: %Y-%m-%d %H:%M", //"%Y-%m-%d %H:%M",
             localtime (&timestamp));
    gtk_widget_set_tooltip_text (win->database_toggle_button, db_text);
}
void SetMouseActionRelTempoSlider(
	struct Tracker_Windows *window,
	struct MouseAction *action,
	int x,int y,
	int click
){
	void *temp;
	struct WBlocks *wblock=window->wblock;

	action->action=RELTEMPOSLIDER;
	if(click==0){
          update_statusbar(window);
          return;
        }
	Undo_RelTempoSlider(window,wblock);

	action->pointer1=wblock;
	action->MouseUpFunction=&MoveRelTempoSlider_Mouse;

	temp=window->prevaction.pointer1;
	window->prevaction.pointer1=wblock;
	MoveRelTempoSlider_Mouse(window,x,0);
	window->prevaction.pointer1=temp;
	
}
Beispiel #3
0
/* callback for updating titlebar, statusbar and playlist on song change event */
static gboolean titlebar_updater(gpointer data) {
	if(MpdWin.window_creation_finished == 1) {
		gtk_window_set_title(GTK_WINDOW(MpdWin.win), title_text);
		if(mpd_info.mps.update) {
		    is_updating_db = TRUE;
            gtk_statusbar_push(GTK_STATUSBAR(StatusBar), sb_push_num++, "mpd: updating database");
		}
		else {
		    if(is_updating_db) {
                is_updating_db = FALSE;
                gtk_statusbar_pop(GTK_STATUSBAR(StatusBar), --sb_push_num);
		    }
            update_statusbar(sb_text, StatusBar);
        }
	}
	if(update_pl_tree == FALSE) {
		update_pl_tree = TRUE;
	}
	if(MpdWin.window_creation_finished == 1) {
		if(mpd_has_current_song_changed())
			playlist_update_tree();
	}
	if((int)data != mpd_info.update_interval) return FALSE;
	return TRUE;
}
static int MoveRelTempoSlider_Mouse(
	struct Tracker_Windows *window,
	float x,float y
){
	struct WBlocks *wblock=window->wblock;

	if(wblock!=(struct WBlocks *)window->prevaction.pointer1) return 0;

	wblock->block->reltempo=R_BOUNDARIES(
		MINBLOCKRELTIME,
		MINBLOCKRELTIME+(((MAXBLOCKRELTIME-MINBLOCKRELTIME)*((float)(x-wblock->reltempo.x1)))/((float)(wblock->reltempo.x2-wblock->reltempo.x1))),
		MAXBLOCKRELTIME
	);

        update_statusbar(window);

	DrawBlockRelTempo(window,wblock);

        TRACKREALLINES_update_peak_tracks(window,NULL);

#if !USE_OPENGL
        WBLOCK_DrawTempoColor(window,wblock,0,wblock->num_reallines);

        DrawUpAllWTracks(window,wblock,NULL);
#endif

	return 0;
}
Beispiel #5
0
void binding_helper_scroll(window_t *w, int offset) {
    ncurses_window_t *n;

    if (!w || !(n = w->priv_data))
        return;

    if (offset < 0) {
        n->start += offset;
        if (n->start < 0)
            n->start = 0;

    } else {
        n->start += offset;

        if (n->start > n->lines_count - w->height + n->overflow)
            n->start = n->lines_count - w->height + n->overflow;

        if (n->start < 0)
            n->start = 0;

        /* old code from: binding_forward_page() need it */
        if (w == window_current) {
            if (ncurses_current->start == ncurses_current->lines_count - window_current->height + ncurses_current->overflow) {
                window_current->more = 0;
                update_statusbar(0);
            }
        }
    }

    ncurses_redraw(w);
    ncurses_commit();
}
Beispiel #6
0
static BINDING_FUNCTION(binding_ui_ncurses_debug_toggle)
{
    if (++ncurses_debug > 3)
        ncurses_debug = 0;

    update_statusbar(1);
}
Beispiel #7
0
static void
activate (GApplication *app)
{
  GtkBuilder *builder;
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *contents;
  GtkWidget *status;
  GtkWidget *message;
  GtkWidget *button;
  GtkWidget *infobar;
  GtkWidget *menutool;
  GMenuModel *toolmenu;
  GtkTextBuffer *buffer;

  window = gtk_application_window_new (GTK_APPLICATION (app));
  gtk_window_set_title (GTK_WINDOW (window), "Application Class");
  gtk_window_set_icon_name (GTK_WINDOW (window), "document-open");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  g_action_map_add_action_entries (G_ACTION_MAP (window),
                                   win_entries, G_N_ELEMENTS (win_entries),
                                   window);

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/application/application.ui", NULL);

  grid = (GtkWidget *)gtk_builder_get_object (builder, "grid");
  contents = (GtkWidget *)gtk_builder_get_object (builder, "contents");
  status = (GtkWidget *)gtk_builder_get_object (builder, "status");
  message = (GtkWidget *)gtk_builder_get_object (builder, "message");
  button = (GtkWidget *)gtk_builder_get_object (builder, "button");
  infobar = (GtkWidget *)gtk_builder_get_object (builder, "infobar");
  menutool = (GtkWidget *)gtk_builder_get_object (builder, "menutool");
  toolmenu = (GMenuModel *)gtk_builder_get_object (builder, "toolmenu");

  g_object_set_data (G_OBJECT (window), "message", message);
  g_object_set_data (G_OBJECT (window), "infobar", infobar);

  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (menutool),
                                 gtk_menu_new_from_model (toolmenu));

  gtk_widget_grab_focus (contents);
  g_signal_connect (button, "clicked", G_CALLBACK (clicked_cb), infobar);

  /* Show text widget info in the statusbar */
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
  g_signal_connect_object (buffer, "changed",
                           G_CALLBACK (update_statusbar), status, 0);
  g_signal_connect_object (buffer, "mark-set",
                           G_CALLBACK (mark_set_callback), status, 0);

  update_statusbar (buffer, GTK_STATUSBAR (status));

  gtk_widget_show_all (window);

  g_object_unref (builder);
}
Beispiel #8
0
    static void
mark_set_callback(GtkTextBuffer *buffer,
        const GtkTextIter *new_location, GtkTextMark *mark,
        gpointer data)
{
    update_statusbar(buffer, GTK_STATUSBAR(data));
}
Beispiel #9
0
int main( int argc, char *argv[])
{

    GtkWidget *window;
    GtkWidget *vbox;

    GtkWidget *toolbar;
    GtkWidget *view;
    GtkWidget *statusbar;
    GtkToolItem *exit;
    GtkTextBuffer *buffer;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(window), 250, 200);
    gtk_window_set_title(GTK_WINDOW(window), "lines & cols");

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);

    exit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), exit, -1);

    gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5);

    view = gtk_text_view_new();
    gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);
    gtk_widget_grab_focus(view);

    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));

    statusbar = gtk_statusbar_new();
    gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);

    g_signal_connect(G_OBJECT(exit), "clicked", 
            G_CALLBACK(gtk_main_quit), NULL);

    g_signal_connect(buffer, "changed",
            G_CALLBACK(update_statusbar), statusbar);

    g_signal_connect_object(buffer, "mark_set", 
            G_CALLBACK(mark_set_callback), statusbar, 0);

    g_signal_connect_swapped(G_OBJECT(window), "destroy",
            G_CALLBACK(gtk_main_quit), NULL);

    gtk_widget_show_all(window);

    update_statusbar(buffer, GTK_STATUSBAR (statusbar));

    gtk_main();

    return 0;
}
Beispiel #10
0
static void move_hscrollbar(Ewl_Scrollpane *s, double direction)
{
    double rel, abs;
    get_horizontal_pan_inc(&rel, &abs);
    rel *= direction;
    ewl_scrollpane_hscrollbar_value_set(s,
            scroll_pos_add(ewl_scrollpane_hscrollbar_value_get(s), rel));
    update_statusbar();
}
static void remove_module(void)
{
	int res;
	char *module;
	char buf[256];
	if (GTK_CLIST(modules)->selection) {
		module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
		gdk_threads_leave();
		res = ast_unload_resource(module, 0);
		gdk_threads_enter();
		if (res) {
			snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
			update_statusbar(buf);
		} else {
			snprintf(buf, sizeof(buf), "Module '%s' removed", module);
			update_statusbar(buf);
		}
	}
}
Beispiel #12
0
static void move_vscrollbar(Ewl_Scrollpane *s, double direction)
{
    double rel, abs;
    get_vertical_pan_inc(&rel, &abs);
    rel *= direction;
    ewl_scrollpane_vscrollbar_value_set(s,
            scroll_pos_add(ewl_scrollpane_vscrollbar_value_get(s), rel));
    display_hint(-abs * direction);
    update_statusbar();
}
static void file_ok_sel(GtkWidget *w, GtkFileSelection *fs)
{
	char tmp[PATH_MAX];
	char *module = gtk_file_selection_get_filename(fs);
	char buf[256];
	snprintf(tmp, sizeof(tmp), "%s/", ast_config_AST_MODULE_DIR);
	if (!strncmp(module, (char *)tmp, strlen(tmp))) 
		module += strlen(tmp);
	gdk_threads_leave();
	if (ast_load_resource(module)) {
		snprintf(buf, sizeof(buf), "Error loading module '%s'.", module);
		update_statusbar(buf);
	} else {
		snprintf(buf, sizeof(buf), "Module '%s' loaded", module);
		update_statusbar(buf);
	}
	gdk_threads_enter();
	gtk_widget_destroy(GTK_WIDGET(fs));
}
Beispiel #14
0
static void
tenso_properties_dialog(GtkButton * CodecButt, struct ALL_DATA *all_data)
{
  struct GWIDGET *gwidget = all_data->gwidget;
  GtkTextIter start, end;
  GtkTextIter iter;

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
      gtk_window_set_default_size(GTK_WINDOW(window), 400, 200);
      gtk_window_set_title(GTK_WINDOW(window), "Tenso incoming data");
      gtk_container_set_border_width(GTK_CONTAINER(window), 5);

  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);

  //-------------------------tool bar--------------------------------------------
  GtkWidget *toolbar = gtk_toolbar_new();
    gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);

  GtkToolItem *startBtn = gtk_tool_button_new_from_stock(GTK_STOCK_OK);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), startBtn, -1);

  GtkToolItem *stopBtn = gtk_tool_button_new_from_stock(GTK_STOCK_CANCEL);
    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), stopBtn, -1);

  gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5);

  GtkWidget *view = gtk_text_view_new();
    gtk_box_pack_start(GTK_BOX(vbox), view, TRUE, TRUE, 0);

  gwidget->tenso_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
    gtk_text_buffer_create_tag(gwidget->tenso_buffer, "gap", "pixels_above_lines", 30, NULL);
    gtk_text_buffer_create_tag(gwidget->tenso_buffer, "lmarg", "left_margin", 5, NULL);
    gtk_text_buffer_create_tag(gwidget->tenso_buffer, "blue_fg", "foreground", "blue", NULL); 
    gtk_text_buffer_get_iter_at_offset(gwidget->tenso_buffer, &iter, 0);

    gtk_text_buffer_insert_with_tags_by_name(gwidget->tenso_buffer, &iter, "Tenso test output\n", -1, "blue_fg", "lmarg",  NULL);
    gtk_text_buffer_insert(gwidget->tenso_buffer, &iter, "Waiting...\n", -1);

  GtkWidget *statusbar = gtk_statusbar_new();
      gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);
      update_statusbar(gwidget->tenso_buffer, GTK_STATUSBAR (statusbar));

  gtk_container_add(GTK_CONTAINER(window), vbox);

 
  g_signal_connect(G_OBJECT(startBtn), "clicked", 
        G_CALLBACK(tenso_startBtn_clicked), all_data);
  
  g_signal_connect(G_OBJECT(stopBtn), "clicked", 
        G_CALLBACK(tenso_stopBtn_clicked), all_data);
  
  gtk_widget_show_all(window);

}
Beispiel #15
0
static void
status_changed_cb (GtkPrintOperation *op,
		   gpointer user_data)
{
  if (gtk_print_operation_is_finished (op))
    {
      active_prints = g_list_remove (active_prints, op);
      g_object_unref (op);
    }
  update_statusbar ();
}
Beispiel #16
0
/* Swap scrollbar values after an orientation change.
 * direction == -1 -> turn clockwise, 1 -> counter-clockwise. */
static void turn_scrollbars(Ewl_Scrollpane *s, int direction)
{
    double h = from_scroll_position(ewl_scrollpane_hscrollbar_value_get(s));
    double v = from_scroll_position(ewl_scrollpane_vscrollbar_value_get(s));

    double new_h =  v * direction;
    double new_v = -h * direction;

    ewl_scrollpane_hscrollbar_value_set(s, to_scroll_position(new_h));
    ewl_scrollpane_vscrollbar_value_set(s, to_scroll_position(new_v));
    update_statusbar();
}
static void reload_module(void)
{
	int res, x;
	char *module;
	char buf[256];
	if (GTK_CLIST(modules)->selection) {
		module= (char *)gtk_clist_get_row_data(GTK_CLIST(modules), (int) GTK_CLIST(modules)->selection->data);
		module = strdup(module);
		if (module) {
			gdk_threads_leave();
			res = ast_unload_resource(module, 0);
			gdk_threads_enter();
			if (res) {
				snprintf(buf, sizeof(buf), "Module '%s' is in use", module);
				update_statusbar(buf);
			} else {
				gdk_threads_leave();
				res = ast_load_resource(module);
				gdk_threads_enter();
				if (res) {
					snprintf(buf, sizeof(buf), "Error reloading module '%s'", module);
				} else {
					snprintf(buf, sizeof(buf), "Module '%s' reloaded", module);
				}
				for (x=0; x < GTK_CLIST(modules)->rows; x++) {
					if (!strcmp((char *)gtk_clist_get_row_data(GTK_CLIST(modules), x), module)) {
						gtk_clist_select_row(GTK_CLIST(modules), x, -1);
						break;
					}
				}
				update_statusbar(buf);
				
			}
			free(module);
		}
	}
}
Beispiel #18
0
gboolean
update_model_cb (gpointer user_data)
{
    DatabaseSearchResult *result = user_data;
    FsearchApplicationWindow *win = result->cb_data;
    FsearchApplication *app = FSEARCH_APPLICATION_DEFAULT;
    FsearchConfig *config = fsearch_application_get_config (app);

    remove_model_from_list (win);
    db_search_results_clear (win->search);

    uint32_t num_results = 0;
    GPtrArray *results = result->results;
    if (results) {
        list_set_results (win->list_model, results);
        win->search->results = results;
        win->search->num_folders = result->num_folders;;
        win->search->num_files = result->num_files;
        num_results = results->len;
    }
    else {
        list_set_results (win->list_model, NULL);
        win->search->results = NULL;
        win->search->num_folders = 0;
        win->search->num_files = 0;
        num_results = 0;
    }

    apply_model_to_list (win);
    gchar sb_text[100] = "";
    snprintf (sb_text, sizeof (sb_text), _("%'d Items"), num_results);
    update_statusbar (win, sb_text);
    reset_sort_order (win);

    const gchar *text = gtk_entry_get_text (GTK_ENTRY (win->search_entry));
    if (text[0] == '\0' && config->hide_results_on_empty_search) {
        show_overlay (win, NO_SEARCH_QUERY_OVERLAY);
    }
    else if (num_results == 0) {
        show_overlay (win, NO_SEARCH_RESULTS_OVERLAY);
    }
    else {
        hide_overlays (win);
    }

    free (result);
    result = NULL;
    return FALSE;
}
int re_populate_items()
{
    int i, cnt=0;
lv_in_op=1;
    ListView_DeleteAllItems(hwnd_lv);
    for(i=0;i<nr_cur_stream;i++)
    {
        InsertItemFromStream(hwnd_lv, g_apt_streams[i]);
        cnt++;

    }
    update_statusbar();
lv_in_op=0;
    return cnt;

}
Beispiel #20
0
static void
print_done (GtkPrintOperation *op,
	    GtkPrintOperationResult res,
	    PrintData *print_data)
{
  GError *error = NULL;

  if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
    {

      GtkWidget *error_dialog;
      
      gtk_print_operation_get_error (op, &error);
      
      error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
					     GTK_DIALOG_DESTROY_WITH_PARENT,
					     GTK_MESSAGE_ERROR,
					     GTK_BUTTONS_CLOSE,
					     "Error printing file:\n%s",
					     error ? error->message : "no details");
      g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
      gtk_widget_show (error_dialog);
    }
  else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
    {
      if (settings != NULL)
	g_object_unref (settings);
      settings = g_object_ref (gtk_print_operation_get_print_settings (op));
    }

  g_free (print_data->text);
  g_free (print_data->font);
  g_free (print_data);
  
  if (!gtk_print_operation_is_finished (op))
    {
      g_object_ref (op);
      active_prints = g_list_append (active_prints, op);
      update_statusbar ();
      
      /* This ref is unref:ed when we get the final state change */
      g_signal_connect (op, "status_changed",
			G_CALLBACK (status_changed_cb), NULL);
    }
}
Beispiel #21
0
/**
 * @brief
 *  Loads a dictionary into the quiz and begins the quiz
 */
void DrillbitWin::on_mnuFileOpenVocabulary_triggered(bool checked)
{
    // get file name
    QString filename;
    filename = QFileDialog::getOpenFileName(this,
            tr("Open drillbit dictionary..."),
            "",
            tr("Lyngo Drillbit Dictionaries (*.ldb)")
    );
    // load it into lyquiz
    if (!filename.isEmpty()) {
        LyDict tmpDict;
        tmpDict.load(filename);
        _quiz.loadDictionary(tmpDict);
        install_preferences();
        _mistakes = 0;
        update_title(true);
        next_question();
        update_statusbar();
    }
}
Beispiel #22
0
static void
update_ui (void)
{
  update_title ();
  update_statusbar ();
}
LRESULT CALLBACK stream_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT		rect ;
    int cxClient, cyClient;
    static HMENU	hMenu ;
    POINT point ;
    int ret, idx;
    TCHAR  buf[64];
    char file_name[MAX_FILE_PATH_LEN];

    static int edit_iItem=-1 ;
    static int edit_iSubItem;

     LVITEM lv_item;
    switch (message)
    {
        case WM_CREATE:
            hwnd_stream= hwnd;
            hMenu = LoadMenu (g_hInstance, TEXT("my_popup_menu")) ;
            hMenu = GetSubMenu (hMenu, 0) ;

            hwnd_dynamic_edit=CreateWindow (TEXT("edit"), TEXT(""),
                WS_CHILD|ES_AUTOHSCROLL,
                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                hwnd, (HMENU)ID_DYNAMIC_EDIT, g_hInstance, NULL) ;

            SendMessage(hwnd_dynamic_edit, WM_SETFONT, (WPARAM)char_font_2, 0); 

            hwnd_lv = CreateListView(hwnd);
            //InitListViewImageLists(hwnd_lv);
            InitListViewColumns(hwnd_lv);
            lv_row_color_init();
            old_lv_proc = (WNDPROC) SetWindowLong (hwnd_lv, 
                                 	GWL_WNDPROC, (LONG)my_lv_proc) ;

            ShowWindow(hwnd_lv, 1) ;
            refresh_window(hwnd_lv) ;

           add_tip(hwndTip, hwnd_lv, TEXT("点击鼠标右键进行操作"));

            return 0 ;

        case WM_SIZE:
      		cxClient = LOWORD (lParam) ;
      		cyClient = HIWORD (lParam) ;

            MoveWindow(hwnd_lv, 	0, 0,
                cxClient, cyClient, TRUE) ;

            return 0 ;

case WM_NOTIFY:
{

   NMHDR *pt_nmhdr=(void *)lParam;
   switch(LOWORD(wParam))
   { 
     case ID_LV:

     // if code == NM_CLICK - Single click on an item
     if(pt_nmhdr->code == NM_CLICK || pt_nmhdr->code == NM_DBLCLK) 
     {
        int iItem = ((LPNMITEMACTIVATE)lParam)->iItem;
        int iSubItem=((LPNMITEMACTIVATE)lParam)->iSubItem;

        if (iItem>=0 && ((iSubItem>=3 && iSubItem<=5) || iSubItem==7)) 
        {

            ListView_GetSubItemRect(hwnd_lv,iItem,iSubItem,LVIR_LABEL,&rect);
            ListView_GetItemText(hwnd_lv, iItem, iSubItem, buf, sizeof(buf));
            MoveWindow	(hwnd_dynamic_edit
                ,rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
            SetWindowText(hwnd_dynamic_edit, buf);
            ShowWindow (hwnd_dynamic_edit, 1) ;
            SetFocus(hwnd_dynamic_edit);
            SendMessage(hwnd_dynamic_edit, EM_SETSEL, (WPARAM)0, (LPARAM)-1);

            edit_iItem = iItem;
            edit_iSubItem = iSubItem;

        }

            return 0;
     }
    else if (pt_nmhdr->code == NM_RCLICK)
    {
        point = ((LPNMITEMACTIVATE)lParam)->ptAction;
        ListView_GetItem(hwnd_lv, &lv_item);

        ClientToScreen (hwnd_lv, &point) ;
  		TrackPopupMenu (hMenu, TPM_LEFTBUTTON, point.x, point.y, 0, hwnd_stream, NULL) ;
        return 0;

    }
    else if (pt_nmhdr->code == LVN_ITEMCHANGED)
    {
        if (!init_over) break;
        if (lv_in_op)   break;
        //if((((LPNMLISTVIEW)lParam)->uOldState&LVIS_STATEIMAGEMASK) != 
        //    (((LPNMLISTVIEW)lParam)->uNewState&LVIS_STATEIMAGEMASK)) 
        {
            int iItem = ((LPNMITEMACTIVATE)lParam)->iItem;
            int selected = ListView_GetCheckState(hwnd_lv, iItem);

            if (g_apt_streams[iItem]->selected!=selected)
            {
                doc_modified=1;
                g_apt_streams[iItem]->selected=selected;
                update_statusbar();
            }
        }
        return 0;

    }
    
    break;

   }

   break;
}

        case 	WM_COMMAND:
            switch (LOWORD(wParam))
            {
                  
                case    IDM_STREAM_NEW:
                    init_stream(&gt_edit_stream);
                    gt_edit_stream.len=gat_sample_pkts[0].len;
                    memcpy(gt_edit_stream.data, gat_sample_pkts[0].pkt_data, gt_edit_stream.len);

                    ret=DialogBox(g_hInstance, TEXT("STREAM_EDIT_DLG"), hwnd, StreamEditDlgProc);
                    if (IDOK==ret)
                    {
                        add_stream(&gt_edit_stream);
                        re_populate_items();
                    }
               	return 0 ;

                case    IDM_STREAM_NEW_HEX:
                {
                    int len;
                    char buf[MAX_PACKET_LEN];
                    if (get_open_file_name(file_name, hwnd, ALL_FILE_FILTER))
                        return 0;

                    len = read_file_to_buf(buf, sizeof(buf)-1, file_name);
                    if (len>0)
                        add_stream_from_hex_text(buf, len);
                    else
                        err_msg_box("读取文件内容失败");
                   	return 0 ;
                }

                case    IDM_STREAM_NEW_BIN:
                {
                    int len;
                    char buf[MAX_PACKET_LEN];
                    if (get_open_file_name(file_name, hwnd, ALL_FILE_FILTER))
                        return 0;

                    len = read_file_to_buf(buf, sizeof(buf)-1, file_name);
                    if (len>0)
                        add_stream_from_raw_data(buf, len);
                    else
                        err_msg_box("读取文件内容失败");
                   	return 0 ;
                }

                case    IDM_STREAM_NEW_PCAP:
                {
                    if (get_open_file_name(file_name, hwnd, PCAP_FILE_FILTER))
                        return 0;
                    add_stream_from_pcap(file_name);
                   	return 0 ;
                }
                                
                case    IDM_STREAM_DEL:
                    idx=GetIndex(hwnd_lv);
       				//ListView_DeleteItem(hwnd_lv, idx);
                    delete_stream(idx);
                    re_populate_items();
                    update_statusbar();
       				return 0 ;
                case    IDM_STREAM_EDIT:
                    cur_strm_idx=GetIndex(hwnd_lv);
                    if (cur_strm_idx<0) return 0;
                    cpy_stream(&gt_edit_stream, g_apt_streams[cur_strm_idx]);
                    ret=DialogBox(g_hInstance, TEXT("STREAM_EDIT_DLG"), hwnd, StreamEditDlgProc);
                    if (IDOK==ret)
                    {
                        doc_modified=1;
                        cpy_stream(g_apt_streams[cur_strm_idx], &gt_edit_stream);
                        re_populate_items();
                    }
       				//ListView_DeleteAllItems(hwnd_lv);
       				return 0 ;
                case    IDM_STREAM_DEL_SEL:
       				//DelSel(hwnd_lv);
                    delete_sel_stream();
                    re_populate_items();
                    update_statusbar();
       				return 0 ;

                case    IDM_STREAM_SEL_ALL:
       				SelAll(hwnd_lv);
       				return 0 ;

                case    IDM_STREAM_SEL_RVS:
       				SelRvs(hwnd_lv);
       				return 0 ;
                    
                case    IDM_STREAM_COPY:
       				copy_idx = GetIndex(hwnd_lv);
       				return 0 ;

                case    IDM_STREAM_PASTE:
       				cpy_stream(&gt_edit_stream, g_apt_streams[copy_idx]);
                    add_stream(&gt_edit_stream);
                    re_populate_items();
       				return 0 ;

                case    IDM_STREAM_MAKE_FRAGS:
                {
       				ret=DialogBox(g_hInstance, TEXT("FRAG_DLG"), hwnd, FragDlgProc);
       				return 0 ;
                }

                case    IDM_STREAM_SEL2PCAP:
                {
                    ret=get_save_file_name(file_name, hwnd, PCAP_FILE_FILTER, PCAP_FILE_SUFFIX);
                    if (ret) return 0 ;

       				stream2dump(file_name);
                    update_pcap_file_history(file_name);
       				return 0 ;
                }

                case    IDM_STREAM_2_BIN:
                {
                    ret=get_save_file_name(file_name, hwnd, BIN_FILE_FILTER, BIN_FILE_SUFFIX);
                    if (ret) return 0 ;

       				stream_2_bin(file_name);
       				return 0 ;
                }

                case    IDM_STREAM_2_TEXT:
                {
                    ret=get_save_file_name(file_name, hwnd, TEXT_FILE_FILTER, TEXT_FILE_SUFFIX);
                    if (ret) return 0 ;

       				stream_2_text(file_name);
       				return 0 ;
                }
                
                case    ID_DYNAMIC_EDIT:
       				if (HIWORD(wParam)==EN_KILLFOCUS)
                    {

            update_grid_from_edit(edit_iItem, edit_iSubItem);
            edit_iItem=-1;

           				return 0 ;
                    }

            }
            break;

case   WM_KEYDOWN:
    if (VK_RETURN==wParam)
    {

        SetFocus(hwnd);

         return 0;

    }
    break;

        case 	WM_INITMENUPOPUP:
        {
            int idx=GetIndex(hwnd_lv);
            t_stream *pt_stream = g_apt_streams[idx];
            int sel_cnt=GetSelCnt(hwnd_lv);
            int item_cnt=ListView_GetItemCount(hwnd_lv);
            if (lParam == 0)
            {
                UINT add_stream_menu_state = nr_cur_stream<MAX_STREAM_NUM ? MF_ENABLED : MF_GRAYED;
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_NEW, add_stream_menu_state);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_NEW_HEX, add_stream_menu_state);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_NEW_BIN, add_stream_menu_state);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_NEW_PCAP, add_stream_menu_state);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_EDIT, idx>=0 ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_DEL, idx>=0 ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_COPY, idx>=0 ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_PASTE, copy_idx>=0 && item_cnt>copy_idx ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_DEL_SEL, sel_cnt ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_SEL_ALL, item_cnt ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_SEL_RVS, item_cnt ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_MAKE_FRAGS, idx>=0&&stream_fragable(pt_stream) ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_SEL2PCAP, sel_cnt ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_2_BIN, idx>=0 ? MF_ENABLED : MF_GRAYED);
                EnableMenuItem ((HMENU) wParam, IDM_STREAM_2_TEXT, idx>=0 ? MF_ENABLED : MF_GRAYED);

                return 0;

            }

            break;
        }

    }
    
    return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Beispiel #24
0
static BINDING_FUNCTION(binding_cycle_sessions)
{
    if (window_session_cycle(window_current) == 0)
        update_statusbar(1);
}
Beispiel #25
0
static void
buffer_changed_callback (GtkTextBuffer *buffer)
{
  file_changed = TRUE;
  update_statusbar ();
}
Beispiel #26
0
static GtkWidget *
do_appwindow (void)
{
  GtkWidget *window;
  GtkWidget *table;
  GtkWidget *toolbar;
  GtkWidget *handlebox;
  GtkWidget *statusbar;
  GtkWidget *contents;
  GtkWidget *sw;
  GtkTextBuffer *buffer;

  #if GTK_CHECK_VERSION(3, 0, 0)
  GtkActionGroup *action_group;
  GtkUIManager *ui_manager;
  #else
  GtkAccelGroup *accel_group;
  GtkItemFactory *item_factory;
  #endif


  /* Create the toplevel window
   */

  ++window_count;

  aspect_on = FALSE;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Application Window");

  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (destroy_cb), NULL);

  table = gtk_table_new (1, 4, FALSE);

  gtk_container_add (GTK_CONTAINER (window), table);

  #if GTK_CHECK_VERSION(3, 0, 0)

  action_group = gtk_action_group_new("ActionGroups");
  gtk_action_group_add_actions(action_group, entries, G_N_ELEMENTS(entries), NULL);

  ui_manager = gtk_ui_manager_new();
  gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
  gtk_ui_manager_add_ui_from_string(ui_manager, ui_definition, -1, NULL);

  gtk_table_attach (GTK_TABLE (table),
					gtk_ui_manager_get_widget (ui_manager, "/MainMenuBar"),
                    /* X direction */          /* Y direction */
                    0, 1,                      0, 1,
                    GTK_EXPAND | GTK_FILL,     0,
                    0,                         0);

  gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui_manager));

  #else

  /* Create the menubar
   */

  accel_group = gtk_accel_group_new ();
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  g_object_unref (accel_group);

  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);

  /* Set up item factory to go away with the window */
  g_object_ref (item_factory);
  g_object_ref_sink (item_factory);
  g_object_unref (item_factory);
  g_object_set_data_full (G_OBJECT (window),
                          "<main>",
                          item_factory,
                          (GDestroyNotify) g_object_unref);

  /* create menu items */
  gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items),
                                 menu_items, window);

  gtk_table_attach (GTK_TABLE (table),
                    gtk_item_factory_get_widget (item_factory, "<main>"),
                    /* X direction */          /* Y direction */
                    0, 1,                      0, 1,
                    GTK_EXPAND | GTK_FILL,     0,
                    0,                         0);


  #endif

  /* Create document
   */

  sw = gtk_scrolled_window_new (NULL, NULL);

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                       GTK_SHADOW_IN);

  gtk_table_attach (GTK_TABLE (table),
                    sw,
                    /* X direction */       /* Y direction */
                    0, 1,                   2, 3,
                    GTK_EXPAND | GTK_FILL,  GTK_EXPAND | GTK_FILL,
                    0,                      0);

  gtk_window_set_default_size (GTK_WINDOW (window),
                               200, 200);

  contents = gtk_text_view_new ();
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
                               PANGO_WRAP_WORD);

  gtk_container_add (GTK_CONTAINER (sw),
                     contents);

  /* Create the toolbar
   */
  toolbar = gtk_toolbar_new ();

  GtkToolItem *newButton = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
  gtk_tool_item_set_tooltip_text(newButton,
				 "Open another one of these windows");
  g_signal_connect(G_OBJECT(newButton),
		   "clicked",
		   G_CALLBACK(do_appwindow),
		   window);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     newButton,
		     -1); /*-1 means append to end of toolbar*/


  GtkToolItem *lockButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
  gtk_tool_item_set_tooltip_text(lockButton,
				 "This is a demo button that locks up the demo");
  g_signal_connect(G_OBJECT(lockButton),
		   "clicked",
		   G_CALLBACK(sleep_cb),
		   window);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     lockButton,
		     -1); /*-1 means append to end of toolbar*/


  GtkToolItem *decoButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
  gtk_tool_item_set_tooltip_text(decoButton,
				 "This is a demo button that toggles window decorations");
  g_signal_connect(G_OBJECT(decoButton),
		   "clicked",
		   G_CALLBACK(toggle_decorated_cb),
		   window);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     decoButton,
		     -1); /*-1 means append to end of toolbar*/

  GtkToolItem *lockRatioButton = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
  gtk_tool_item_set_tooltip_text(lockRatioButton,
				 "This is a demo button that locks the aspect ratio using a hint");
  g_signal_connect(G_OBJECT(lockRatioButton),
		   "clicked",
		   G_CALLBACK(toggle_aspect_ratio),
		   window);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     lockRatioButton,
		     -1); /*-1 means append to end of toolbar*/

  GtkToolItem *quitButton = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
  gtk_tool_item_set_tooltip_text(quitButton,
				 "This is a demo button with a 'quit' icon");
  g_signal_connect(G_OBJECT(quitButton),
		   "clicked",
		   G_CALLBACK(clicked_toolbar_cb),
		   window);
  gtk_toolbar_insert(GTK_TOOLBAR(toolbar),
		     quitButton,
		     -1); /*-1 means append to end of toolbar*/

  handlebox = gtk_handle_box_new ();

  gtk_container_add (GTK_CONTAINER (handlebox), toolbar);

  gtk_table_attach (GTK_TABLE (table),
                    handlebox,
                    /* X direction */       /* Y direction */
                    0, 1,                   1, 2,
                    GTK_EXPAND | GTK_FILL,  0,
                    0,                      0);

  /* Create statusbar */

  statusbar = gtk_statusbar_new ();
  gtk_table_attach (GTK_TABLE (table),
                    statusbar,
                    /* X direction */       /* Y direction */
                    0, 1,                   3, 4,
                    GTK_EXPAND | GTK_FILL,  0,
                    0,                      0);

  /* Show text widget info in the statusbar */
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));

  gtk_text_buffer_set_text (buffer,
                            "This demo demonstrates various kinds of windows that "
                            "window managers and window manager themes should handle. "
                            "Be sure to tear off the menu and toolbar, those are also "
                            "a special kind of window.",
                            -1);

  g_signal_connect_object (buffer,
                           "changed",
                           G_CALLBACK (update_statusbar),
                           statusbar,
                           0);

  g_signal_connect_object (buffer,
                           "mark_set", /* cursor moved */
                           G_CALLBACK (mark_set_callback),
                           statusbar,
                           0);

  update_statusbar (buffer, GTK_STATUSBAR (statusbar));

  gtk_widget_show_all (window);

  return window;
}
Beispiel #27
0
int *popen_re_unbuffered(char *command) {
  static int p_r[2] = { -1, -1 }, p_e[2] = {
  -1, -1};
  static int *pfd = NULL;

  char *options[128];
  hydra_pid = 0;

  update_statusbar();

  /* only allocate once */
  if (NULL == pfd)
    pfd = malloc(sizeof(int) * 2);

  /* clean up from last command */
  close_pipe(p_r);
  close_pipe(p_e);

  if (pipe(p_r) < 0 || pipe(p_e) < 0) {
    g_warning("popen_rw_unbuffered: Error creating pipe!");
    return NULL;
  }

  if ((hydra_pid = fork()) < 0) {
    g_warning("popen_rw_unbuffered: Error forking!");
    return NULL;
  } else if (hydra_pid == 0) {  /* child */
    int k;
    if (setpgid(getpid(), getpid()) < 0)
      g_warning("popen_rw_unbuffered: setpgid() failed");
    if (close(p_r[0]) < 0)
      g_warning("popen_rw_unbuffered: close(p_r[0]) failed");
    if (p_r[1] != STDOUT_FILENO)
      if (dup2(p_r[1], STDOUT_FILENO) < 0)
        g_warning("popen_rw_unbuffered: child dup2 STDOUT failed!");
    if (close(p_r[1]) < 0)
      g_warning("popen_rw_unbuffered: close(p_r[1]) failed");

    if (close(p_e[0]) < 0)
      g_warning("popen_rw_unbuffered: close(p_e[0]) failed");
    if (p_e[1] != STDERR_FILENO)
      if (dup2(p_e[1], STDERR_FILENO) < 0)
        g_warning("popen_rw_unbuffered: child dup2 STDERR failed!");
    if (close(p_e[1]) < 0)
      g_warning("popen_rw_unbuffered: close(p_e[1]) failed");

    (void) hydra_get_options(options);

    execv(HYDRA_BIN, options);

    g_warning("%s %i: popen_rw_unbuffered: execv() returned", __FILE__, __LINE__);
    
    for (k = 0; options[k] != NULL; k++) {
      g_warning("%s", options[k]);
    }
    gtk_main_quit();
  } else {                      /* parent */
    if (close(p_r[1]) < 0)
      g_warning("popen_rw_unbuffered: close(p_r[1]) (parent) failed");
    if (close(p_e[1]) < 0)
      g_warning("popen_rw_unbuffered: close(p_e[1]) (parent) failed");
    pfd[0] = p_r[0];
    pfd[1] = p_e[0];
    return pfd;
  }
  g_assert_not_reached();
  return pfd;
}
Beispiel #28
0
static void
do_appwindow (GSimpleAction *action,
              GVariant      *parameter,
              gpointer       user_data)
{
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *statusbar;
  GtkWidget *contents;
  GtkWidget *sw;
  GtkTextBuffer *buffer;
  GSimpleActionGroup *action_group;
  GtkBuilder *builder;
  GMenuModel *model;
  GtkWidget *menubar;
  GtkWidget *toolbar;

  /* Create the toplevel window
   */

  ++window_count;

  aspect_on = FALSE;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Application Window");

  g_signal_connect (G_OBJECT (window), "destroy",
                    G_CALLBACK (destroy_cb), NULL);

  grid = gtk_grid_new ();

  gtk_widget_set_vexpand (grid, TRUE);
  gtk_widget_set_hexpand (grid, TRUE);

  gtk_container_add (GTK_CONTAINER (window), grid);

  action_group = g_simple_action_group_new ();
  builder = gtk_builder_new_from_string (xml, -1);

  g_action_map_add_action_entries (G_ACTION_MAP (action_group),
                                   demo_entries,
                                   G_N_ELEMENTS (demo_entries),
                                   window);
  gtk_widget_insert_action_group (window, "demo", G_ACTION_GROUP (action_group));

  /* Create the menubar
   */

  model = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
  menubar = gtk_menu_bar_new_from_model (model);
  gtk_grid_attach (GTK_GRID (grid), menubar, 0, 0, 1, 1);
  gtk_widget_set_hexpand (menubar, TRUE);

  /* Create the toolbar
   */

  toolbar = create_toolbar ();
  gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 1, 1, 1);
  gtk_widget_set_hexpand (toolbar, TRUE);

  /* Create document
   */

  contents = gtk_text_view_new ();

  sw = gtk_scrolled_window_new (NULL, NULL);

  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);

  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
                                       GTK_SHADOW_IN);

  gtk_grid_attach (GTK_GRID (grid), sw, 0, 2, 1, 1);

  gtk_widget_set_hexpand (sw, TRUE);
  gtk_widget_set_vexpand (sw, TRUE);

  gtk_window_set_default_size (GTK_WINDOW (window),
                               200, 200);

  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (contents),
                               PANGO_WRAP_WORD);

  gtk_container_add (GTK_CONTAINER (sw),
                     contents);

  /* Create statusbar
   */

  statusbar = gtk_statusbar_new ();
  gtk_grid_attach (GTK_GRID (grid), statusbar, 0, 3, 1, 1);
  gtk_widget_set_hexpand (statusbar, TRUE);

  /* Show text widget info in the statusbar */

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));

  gtk_text_buffer_set_text (buffer,
                            "This demo demonstrates various kinds of windows that "
                            "window managers and window manager themes should handle. "
                            "Be sure to tear off the menu and toolbar, those are also "
                            "a special kind of window.",
                            -1);

  g_signal_connect_object (buffer,
                           "changed",
                           G_CALLBACK (update_statusbar),
                           statusbar,
                           0);

  g_signal_connect_object (buffer,
                           "mark_set", /* cursor moved */
                           G_CALLBACK (mark_set_callback),
                           statusbar,
                           0);

  update_statusbar (buffer, GTK_STATUSBAR (statusbar));

  gtk_widget_show_all (window);

  g_object_unref (action_group);
  g_object_unref (builder);
}
Beispiel #29
0
int doGUI(int argc, char *argv[]) {
	GtkWidget *vbox;

	GtkWidget *toolbar;
	GtkWidget *view;
	GtkWidget* scrolledwindow;
	GtkWidget *statusbar;
	GtkToolItem *exit;
	GtkToolItem *properties;
	GtkToolItem *connect;
	GtkTextBuffer *buffer;
	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_default_size(GTK_WINDOW(window), WINDOW_WIDTH, WINDOW_HEIGHT);
	gtk_window_set_title(GTK_WINDOW(window), MAIN_GUI_TITLE);

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	toolbar = gtk_toolbar_new();
	gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);

	exit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), exit, -1);

	connect = gtk_tool_button_new_from_stock(GTK_STOCK_CONNECT);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), connect, -1);

	properties = gtk_tool_button_new_from_stock(GTK_STOCK_PROPERTIES);
	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), properties, -1);

	gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5);

	view = gtk_text_view_new();
	scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
	gtk_container_add(GTK_CONTAINER(scrolledwindow), view);
	gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
	gtk_widget_grab_focus(view);

	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));

	statusbar = gtk_statusbar_new();
	gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0);

	g_signal_connect(G_OBJECT(exit), "clicked",
			G_CALLBACK(gtk_main_quit), NULL);

	g_signal_connect(G_OBJECT(connect), "clicked",
			G_CALLBACK(connectSerial), NULL);

	g_signal_connect(G_OBJECT(properties), "clicked",
			G_CALLBACK(doProperties), NULL);

	g_signal_connect(buffer, "changed",
			G_CALLBACK(update_statusbar), statusbar);

	g_signal_connect_object(buffer, "mark_set",
			G_CALLBACK(mark_set_callback), statusbar, 0);

	g_signal_connect_swapped(G_OBJECT(window), "destroy",
			G_CALLBACK(gtk_main_quit), NULL);

	g_timeout_add(300, (GSourceFunc) time_handler, (gpointer) view);

	gtk_widget_show_all(window);

	update_statusbar(buffer, GTK_STATUSBAR (statusbar));

	gtk_main();

	return 0;
}
Beispiel #30
0
static void
update_ui (void)
{
  update_title (GTK_WINDOW (main_window));
  update_statusbar ();
}