Logo Search packages:      
Sourcecode: pan version File versions

GUI::GUI ( Data data,
Queue queue,
ArticleCache cache,
Prefs prefs,
GroupPrefs &  group_prefs 
)

Status Bar

Definition at line 137 of file gui.cc.

References pan::Prefs::add_listener(), pan::Queue::add_listener(), pan::HeaderPane::create_filter_entry(), pan::GroupPane::create_filter_entry(), pan::Prefs::get_flag(), pan::file::get_pan_home(), pan::Queue::get_task_counts(), pan::BodyPane::root(), pan::HeaderPane::root(), pan::GroupPane::root(), and pan::ProgressView::root().

                                                                                               :
  _data (data),
  _queue (queue),
  _cache (cache),
  _prefs (prefs),
  _group_prefs (group_prefs),
  _root (gtk_vbox_new (FALSE, 0)),
  _menu_vbox (gtk_vbox_new (FALSE, 0)),
  _group_pane (0),
  _header_pane (0),
  _body_pane (0),
  _ui_manager (gtk_ui_manager_new ()),
  _info_image (gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_MENU)),
  _error_image (gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU)),
  _connection_size_eventbox (0),
  _connection_size_label (0),
  _queue_size_label (0),
  _queue_size_button (0),
  _taskbar (0),
  _ttips (gtk_tooltips_new ())
{
  char * filename = g_build_filename (file::get_pan_home().c_str(), "pan.ui", NULL);
#if 0
  GError * gerr (0);
  gtk_ui_manager_add_ui_from_file (_ui_manager, filename, &gerr);
  if (gerr)  {
    Log::add_err (gerr->message);
    g_clear_error (&gerr);
  }
#else
  if (!gtk_ui_manager_add_ui_from_file (_ui_manager, filename, NULL))
    gtk_ui_manager_add_ui_from_string (_ui_manager, fallback_ui_file, -1, NULL);
#endif
  g_free (filename);
  g_signal_connect (_ui_manager, "add_widget", G_CALLBACK (add_widget), this);
  add_actions (this, _ui_manager, &prefs);
  g_signal_connect (_root, "parent-set", G_CALLBACK(parent_set_cb), _ui_manager);
  gtk_box_pack_start (GTK_BOX(_root), _menu_vbox, FALSE, FALSE, 0);
  gtk_widget_show (_menu_vbox);

  //_group_pane = new GroupPane (*this, data, _prefs);
  _group_pane = new GroupPane (*this, data, _prefs);
  _header_pane = new HeaderPane (*this, data, _queue, _cache, _prefs);
  _body_pane = new BodyPane (data, _cache, _prefs);

  std::string path = "/ui/main-window-toolbar";
  GtkWidget * toolbar = gtk_ui_manager_get_widget (_ui_manager, path.c_str());
  path += "/group-pane-filter";
  GtkWidget * w = gtk_ui_manager_get_widget (_ui_manager, path.c_str());
  int index = gtk_toolbar_get_item_index (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(w));
  GtkToolItem * item = gtk_tool_item_new ();
  gtk_container_add (GTK_CONTAINER(item), _group_pane->create_filter_entry());
  gtk_widget_show_all (GTK_WIDGET(item));
  gtk_toolbar_insert (GTK_TOOLBAR(toolbar), item, index+1);
  path = "/ui/main-window-toolbar/header-pane-filter";
  w = gtk_ui_manager_get_widget (_ui_manager, path.c_str());
  index = gtk_toolbar_get_item_index (GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(w));
  item = gtk_tool_item_new ();
  gtk_container_add (GTK_CONTAINER(item), _header_pane->create_filter_entry());
  gtk_widget_show_all (GTK_WIDGET(item));
  gtk_toolbar_insert (GTK_TOOLBAR(toolbar), item, index+1);
  
  //guint merge_id = gtk_ui_manager_new_merge_id (_ui_manager);
  //gtk_ui_manager_add_ui (_ui_manager, merge_id, path, "group-pane-filter", NULL, GTK_UI_MANAGER_TOOLITEM, true);
  //GtkWidget * item = gtk_ui_manager_get_widget (_ui_manager, path);
  //gtk_container_add (GTK_CONTAINER(item), _group_pane->create_filter_entry());


  // workarea
  _workarea_bin = gtk_event_box_new ();
  do_tabbed_layout (is_action_active ("tabbed-layout"));
  gtk_box_pack_start (GTK_BOX(_root), _workarea_bin, TRUE, TRUE, 0);
  gtk_widget_show (_workarea_bin);

  /**
  ***  Status Bar
  **/

  w = gtk_event_box_new ();
  gtk_widget_set_size_request (w, -1, PAD_SMALL);
  gtk_box_pack_start (GTK_BOX(_root), w, false, false, 0);
  gtk_widget_show (w);

  GtkWidget * status_bar (gtk_hbox_new (FALSE, 0));

  // connection status
  w = _connection_size_label = gtk_label_new (NULL);
  gtk_misc_set_padding (GTK_MISC(w), PAD, 0);
  _connection_size_eventbox = gtk_event_box_new ();
  gtk_container_add (GTK_CONTAINER(_connection_size_eventbox), w);
  w = _connection_size_eventbox;
  GtkWidget * frame = gtk_frame_new (NULL);
  gtk_container_set_border_width (GTK_CONTAINER(frame), 0);
  gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER(frame), w);
  gtk_box_pack_start (GTK_BOX(status_bar), frame, FALSE, FALSE, 0);

  // queue
  w = _queue_size_label = gtk_label_new (NULL);
  gtk_misc_set_padding (GTK_MISC(w), PAD, 0);
  w = _queue_size_button = gtk_button_new();
  gtk_tooltips_set_tip (GTK_TOOLTIPS(_ttips), w, _("Open the Task Manager"), NULL);
  gtk_button_set_relief (GTK_BUTTON(w), GTK_RELIEF_NONE);
  g_signal_connect (GTK_OBJECT(w), "clicked", G_CALLBACK(show_task_window_cb), this);
  gtk_container_add (GTK_CONTAINER(w), _queue_size_label);
  frame = gtk_frame_new (NULL);
  gtk_container_set_border_width (GTK_CONTAINER(frame), 0);
  gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
  gtk_container_add (GTK_CONTAINER(frame), w);
  gtk_box_pack_start (GTK_BOX(status_bar), frame, FALSE, FALSE, 0);

  // status item views
  _taskbar = gtk_table_new (1, VIEW_QTY, TRUE);
  for (int i=0; i<VIEW_QTY; ++i) {
    ProgressView * v = new ProgressView ();
    gtk_table_attach (GTK_TABLE(_taskbar), v->root(), i, i+1, 0, 1, (GtkAttachOptions)~0, (GtkAttachOptions)~0, 0, 0);
    _views.push_back (v);
  }
  gtk_box_pack_start (GTK_BOX(status_bar), _taskbar, true, true, 0);
  gtk_widget_show_all (status_bar);

  // status 
  w = _event_log_button = gtk_button_new ();
  gtk_tooltips_set_tip (GTK_TOOLTIPS(_ttips), w, _("Open the Event Log"), NULL);
  gtk_button_set_relief (GTK_BUTTON(w), GTK_RELIEF_NONE);
  gtk_box_pack_start (GTK_BOX(status_bar), w, false, false, 0);
  gtk_container_add (GTK_CONTAINER(w), _info_image);
  g_signal_connect (w, "clicked", G_CALLBACK(show_event_log_cb), this);

  gtk_box_pack_start (GTK_BOX(_root), status_bar, false, false, 0);
  gtk_widget_show_all (status_bar);

  gtk_widget_show (_root);

  upkeep_tag = g_timeout_add (3000, upkeep_timer_cb, this);

  _queue.add_listener (this);
  Log::get().add_listener (this);

  gtk_widget_ref (_info_image);
  gtk_widget_ref (_error_image);
  gtk_widget_ref (_group_pane->root());
  gtk_widget_ref (_header_pane->root());
  gtk_widget_ref (_body_pane->root());

  gtk_object_sink (GTK_OBJECT (_info_image));
  gtk_object_sink (GTK_OBJECT (_error_image));

  do_work_online (is_action_active ("work-online"));

  // update the connections label
  upkeep_timer_cb (this);

  // update the queue label
  int active(0), total(0);
  _queue.get_task_counts (active, total);
  set_queue_size_label (active, total);

  if (_prefs.get_flag ("get-new-headers-on-startup", false))
    activate_action ("get-new-headers-in-subscribed-groups");

  _prefs.add_listener (this);

  g_object_ref (_ttips);
  gtk_object_sink (GTK_OBJECT(_ttips));
  g_signal_connect_swapped (_root, "destroy", G_CALLBACK(g_object_unref), _ttips);

  gtk_accel_map_load (get_accel_filename().c_str());
}


Generated by  Doxygen 1.6.0   Back to index