Exemplo n.º 1
0
bool
NativeKeyBindings::ExecuteInternal(const WidgetKeyboardEvent& aEvent,
                                   DoCommandCallback aCallback,
                                   void* aCallbackData,
                                   guint aKeyval)
{
  guint modifiers =
    static_cast<GdkEventKey*>(aEvent.mNativeKeyEvent)->state;

  gCurrentCallback = aCallback;
  gCurrentCallbackData = aCallbackData;

  gHandled = false;
#if (MOZ_WIDGET_GTK == 2)
  gtk_bindings_activate(GTK_OBJECT(mNativeTarget),
                        aKeyval, GdkModifierType(modifiers));
#else
  gtk_bindings_activate(G_OBJECT(mNativeTarget),
                        aKeyval, GdkModifierType(modifiers));
#endif

  gCurrentCallback = nullptr;
  gCurrentCallbackData = nullptr;

  return gHandled;
}
Exemplo n.º 2
0
static void buildMenu(GtkWidget *menu, GtkWidget **copy_to_clipboard, GtkWidget **nearest_from_palette)
{
	GtkAccelGroup *accel_group = gtk_menu_get_accel_group(GTK_MENU(menu));
	GtkWidget *item = *copy_to_clipboard = gtk_menu_item_new_with_mnemonic(_("_Copy to clipboard"));
	if (accel_group)
		gtk_widget_add_accelerator(item, "activate", accel_group, GDK_KEY_c, GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
	item = *nearest_from_palette = gtk_menu_item_new_with_mnemonic(_("_Nearest from palette"));
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
}
Exemplo n.º 3
0
gint
KeymapWrapper::GetKeyLevel(GdkEventKey *aGdkKeyEvent)
{
    gint level;
    if (!gdk_keymap_translate_keyboard_state(mGdkKeymap,
             aGdkKeyEvent->hardware_keycode,
             GdkModifierType(aGdkKeyEvent->state),
             aGdkKeyEvent->group, NULL, NULL, &level, NULL)) {
        return -1;
    }
    return level;
}
Exemplo n.º 4
0
/* static */ guint
KeymapWrapper::GetGDKKeyvalWithoutModifier(const GdkEventKey *aGdkKeyEvent)
{
    KeymapWrapper* keymapWrapper = GetInstance();
    guint state =
        (aGdkKeyEvent->state & keymapWrapper->GetModifierMask(NUM_LOCK));
    guint keyval;
    if (!gdk_keymap_translate_keyboard_state(keymapWrapper->mGdkKeymap,
             aGdkKeyEvent->hardware_keycode, GdkModifierType(state),
             aGdkKeyEvent->group, &keyval, NULL, NULL, NULL)) {
        return 0;
    }
    return keyval;
}
Exemplo n.º 5
0
Gtk::ImageMenuItem * new_toc_menu_item ()
//create a menu item like: "[]_Table_of_Contents______Ctrl-Alt-1__>"
{
    Gtk::ImageMenuItem * menu_item = manage(new Gtk::ImageMenuItem ());
    menu_item->set_image(*manage(new Gtk::Image(Gtk::Stock::JUMP_TO, Gtk::ICON_SIZE_MENU)));

    Gtk::AccelLabel *acclabel = manage(new Gtk::AccelLabel(_("Table of Contents")));
    acclabel->set_alignment (Gtk::ALIGN_START);
    /* I don't have gtkmm-3.6, but I have gtk-3.6 */
    /* TO UNCOMMENT *///acclabel->set_accel (GDK_KEY_1, Gdk::CONTROL_MASK | Gdk::MOD1_MASK);
    /* TO DELETE    */gtk_accel_label_set_accel (acclabel->gobj (),GDK_KEY_1, GdkModifierType (GDK_CONTROL_MASK | GDK_MOD1_MASK));
    acclabel->show ();

    menu_item->add (*acclabel);

    return menu_item;
}
Exemplo n.º 6
0
PRUint32
KeymapWrapper::GetCharCodeFor(const GdkEventKey *aGdkKeyEvent,
                              guint aModifierState,
                              gint aGroup)
{
    guint keyval;
    if (!gdk_keymap_translate_keyboard_state(mGdkKeymap,
             aGdkKeyEvent->hardware_keycode,
             GdkModifierType(aModifierState),
             aGroup, &keyval, NULL, NULL, NULL)) {
        return 0;
    }
    GdkEventKey tmpEvent = *aGdkKeyEvent;
    tmpEvent.state = aModifierState;
    tmpEvent.keyval = keyval;
    tmpEvent.group = aGroup;
    return GetCharCodeFor(&tmpEvent);
}
Exemplo n.º 7
0
EvAlaGtk::EvAlaGtk( void *ev_parent_ctx,
		    GtkWidget	*ev_parent_wid,
		    char *ala_name,
		    pwr_tObjid ev_user,
		    int ev_eventname_seg,
		    int ev_width,
		    int ev_height,
		    int ev_x,
		    int ev_y,
		    pwr_tObjid ev_view,
		    unsigned int ev_options,
		    void *widget,
		    pwr_tStatus *status) :
  EvAla( ev_parent_ctx, ala_name, ev_user, ev_eventname_seg, 
	 ev_width, ev_height, ev_x, ev_y, ev_view, ev_options, status),
  parent_wid(ev_parent_wid), toplevel(0)
{
  pwr_tStatus sts;
  pwr_sClass_OpPlace *opp;
  pwr_tFileName fname;
  int ala_width = 700;
  int ala_height = 300;

  *status = 1;

  if ( ev_width != 0 && ev_height != 0) {
    ala_width = ev_width;
    ala_height = ev_height;
  }

  // Check user object
  if ( cdh_ObjidIsNull( user)) {
    *status = XNAV__NOUSER;
    return;
  }

  sts = gdh_ObjidToPointer( user, (pwr_tAddress *) &opp);
  if ( EVEN(sts)) {
    *status = XNAV__NOUSER;
    return;
  }
  ala_size = opp->MaxNoOfAlarms;
  // create_aliaslist( opp);

  // Ala Window

  if ( !(options & ev_mAlaOptions_Embedded)) {
    toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
						 "default-height", ala_height,
						 "default-width", ala_width,
						 "title", CoWowGtk::translate_utf8(ala_name),
						 NULL);
    parent_wid_ala = toplevel;
    g_signal_connect( parent_wid_ala, "delete_event", G_CALLBACK(ala_delete_event), this);
    g_signal_connect( parent_wid_ala, "destroy", G_CALLBACK(ala_destroy_event), this);
    g_signal_connect( parent_wid_ala, "focus-in-event", G_CALLBACK(ala_action_inputfocus), this);

    CoWowGtk::SetWindowIcon( parent_wid_ala);
  }
  else
    parent_wid_ala = (GtkWidget *)widget;

  ala_vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(parent_wid_ala), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print), 
				 gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_print, "activate", G_CALLBACK(ala_activate_print), this);

  GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), 
				 gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(ala_activate_exit), this);
  gtk_widget_add_accelerator( file_close, "activate", accel_g,
			      'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget *functions_ack_last = gtk_menu_item_new_with_mnemonic( 
								  CoWowGtk::translate_utf8("_Acknowledge"));
  g_signal_connect( functions_ack_last, "activate", 
		    G_CALLBACK(ala_activate_ack_last), this);
  gtk_widget_add_accelerator( functions_ack_last, "activate", accel_g,
			      'k', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_ack_all = gtk_menu_item_new_with_mnemonic( 
								 CoWowGtk::translate_utf8("A_cknowledge All"));
  g_signal_connect( functions_ack_all, "activate", 
		    G_CALLBACK(ala_activate_ack_all), this);

  GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( 
								  CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect( functions_open_plc, "activate", 
		    G_CALLBACK(ala_activate_open_plc), this);
  gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
			      'l', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic( 
									CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect( functions_display_object, "activate", 
		    G_CALLBACK(ala_activate_display_in_xnav), this);
  gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
			      'd', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_last);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_all);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // View entry
  GtkWidget *view_shift_view = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("S_hift View"));
  g_signal_connect( view_shift_view, "activate", 
		    G_CALLBACK(ala_activate_shift_view), this);
  gtk_widget_add_accelerator( view_shift_view, "activate", accel_g,
			      'n', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in), 
				 gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_in, "activate", 
		    G_CALLBACK(ala_activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out), 
				 gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_out, "activate", 
		    G_CALLBACK(ala_activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GdkModifierType(GDK_CONTROL_MASK),
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset), 
				 gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect( view_zoom_reset, "activate", 
		    G_CALLBACK(ala_activate_zoom_reset), this);
  gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
			      'b', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_disp_hundredth = gtk_check_menu_item_new_with_mnemonic( 
									 CoWowGtk::translate_utf8("_Display hundredth"));
  g_signal_connect( view_disp_hundredth, "activate", 
		    G_CALLBACK(ala_activate_disp_hundredth), this);

  GtkWidget *view_hide_object = gtk_check_menu_item_new_with_mnemonic( 
								      CoWowGtk::translate_utf8("_Hide Event Name"));
  g_signal_connect( view_hide_object, "activate", 
		    G_CALLBACK(ala_activate_hide_object), this);

  GtkWidget *view_hide_text = gtk_check_menu_item_new_with_mnemonic( 
								    CoWowGtk::translate_utf8("Hide _Event Text"));
  g_signal_connect( view_hide_text, "activate", 
		    G_CALLBACK(ala_activate_hide_text), this);

  // Submenu Select View
  GtkWidget *view_select_flat = gtk_menu_item_new_with_mnemonic( "_Flat");
  g_signal_connect( view_select_flat, "activate", 
		    G_CALLBACK(ala_activate_select_flat), this);


  GtkWidget *view_select = gtk_menu_item_new_with_mnemonic( "_Select View");
  GtkMenu *view_select_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_select_menu), view_select_flat);

  for ( unsigned int i = 0; i < sizeof(opp->AlarmViews)/sizeof(opp->AlarmViews[0]); i++) {
    pwr_sClass_AlarmView *viewp;

    if ( cdh_ObjidIsNull( opp->AlarmViews[i]))
      break;
      
    sts = gdh_ObjidToPointer( opp->AlarmViews[i], (void **)&viewp);
    if ( ODD(sts)) {
      alarm_views[i] = opp->AlarmViews[i];
      GtkWidget *view_select_view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8(viewp->Name));
      switch ( i) {
      case 0: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view1), this); break;
      case 1: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view2), this); break;
      case 2: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view3), this); break;
      case 3: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view4), this); break;
      case 4: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view5), this); break;
      case 5: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view6), this); break;
      case 6: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view7), this); break;
      case 7: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view8), this); break;
      case 8: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view9), this); break;
      case 9: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view10), this); break;
      case 10: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view11), this); break;
      case 11: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view12), this); break;
      case 12: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view13), this); break;
      case 13: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view14), this); break;
      case 14: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view15), this); break;
      case 15: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view16), this); break;
      case 16: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view17), this); break;
      case 17: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view18), this); break;
      case 18: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view19), this); break;
      case 19: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view20), this); break;
      case 20: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view21), this); break;
      case 21: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view22), this); break;
      case 22: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view23), this); break;
      case 23: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view24), this); break;
      case 24: g_signal_connect( view_select_view, "activate", G_CALLBACK(ala_activate_select_view25), this); break;
      }
      gtk_menu_shell_append(GTK_MENU_SHELL(view_select_menu), view_select_view);
    }
  }

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_select),
			      GTK_WIDGET(view_select_menu));

    GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_shift_view);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_select);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_disp_hundredth);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_object);
    gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_text);

    GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

    // Help entry
    GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic( 
                              CoWowGtk::translate_utf8("_Help"));
    gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				   gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
    g_signal_connect(help_help, "activate", G_CALLBACK(ala_activate_help), this);
    gtk_widget_add_accelerator( help_help, "activate", accel_g,
				'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    GtkWidget *help_helpevent = gtk_menu_item_new_with_mnemonic( 
                                         CoWowGtk::translate_utf8("Help Selected Event"));
    g_signal_connect( help_helpevent, "activate", 
		      G_CALLBACK(ala_activate_helpevent), this);

    GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
    gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_helpevent);

    GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

    // Create ala evlist
    ala = new EvListGtk( this, ala_vbox, ev_eType_AlarmList, ala_size, eventname_seg, 
			 &ala_widget, ala_init_cb);
    ala->start_trace_cb = &ala_start_trace_cb;
    ala->display_in_xnav_cb =&ala_display_in_xnav_cb;
    ala->name_to_alias_cb = &ala_name_to_alias_cb;
    ala->popup_menu_cb = &ala_popup_menu_cb;
    ala->sound_cb = &ala_sound_cb;
    ala->help_event_cb = &help_event_cb;
    ala->selection_changed_cb = &ala_selection_changed_cb;
  
    // Toolbar
    GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

    GtkWidget *tools_ack = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_acknowledge.png");
    gtk_container_add( GTK_CONTAINER( tools_ack), gtk_image_new_from_file( fname));
    g_signal_connect(tools_ack, "clicked", G_CALLBACK(ala_activate_ack_last), this);
    g_object_set( tools_ack, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_ack, CoWowGtk::translate_utf8("Acknowledge"), "");
    
    GtkWidget *tools_zoom_in = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(ala_activate_zoom_in), this);
    g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_in,CoWowGtk::translate_utf8("Zoom in"), "");

    GtkWidget *tools_zoom_out = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(ala_activate_zoom_out), this);
    g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_out,CoWowGtk::translate_utf8("Zoom out"), "");
    
    GtkWidget *tools_zoom_reset = gtk_button_new();
    dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
    gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		       gtk_image_new_from_file( fname));
    g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(ala_activate_zoom_reset), this);
    g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
    gtk_toolbar_append_widget( tools, tools_zoom_reset,CoWowGtk::translate_utf8("Zoom reset"), "");
    
    ala_methodtoolbar = new XttMethodToolbarGtk(0, 0, ~0, "");
    GtkToolbar *tools_meth = (GtkToolbar *) ((XttMethodToolbarGtk *)ala_methodtoolbar)->build();

    ala_methodtoolbar->m_xnav = (XNav *)((Ev *)parent_ctx)->parent_ctx;
    ala_methodtoolbar->m_parent_ctx = ala;
    ala_methodtoolbar->get_select_cb = ala->get_select;

    ala_sup_methodtoolbar = new XttMethodToolbarGtk(0, 0, mt_mMethod_OpenPlc | mt_mMethod_RtNavigator, 
						    " for supervisory object");
    GtkToolbar *tools_sup = (GtkToolbar *) ((XttMethodToolbarGtk *)ala_sup_methodtoolbar)->build();
    ala_sup_methodtoolbar->m_xnav = (XNav *)((Ev *)parent_ctx)->parent_ctx;
    ala_sup_methodtoolbar->m_parent_ctx = ala;
    ala_sup_methodtoolbar->get_select_cb = ala->get_select_supobject;

    GtkWidget *ala_toolsbox = gtk_hbox_new( FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(gtk_separator_tool_item_new()), FALSE, FALSE, 4);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools_sup), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(gtk_separator_tool_item_new()), FALSE, FALSE, 4);
    gtk_box_pack_start( GTK_BOX(ala_toolsbox), GTK_WIDGET(tools_meth), FALSE, FALSE, 0);

    gtk_box_pack_start( GTK_BOX(ala_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
    gtk_box_pack_start( GTK_BOX(ala_vbox), GTK_WIDGET(ala_toolsbox), FALSE, FALSE, 0);
    gtk_box_pack_end( GTK_BOX(ala_vbox), GTK_WIDGET(ala_widget), TRUE, TRUE, 0);

    if ( !(options & ev_mAlaOptions_Embedded)) {
      gtk_container_add( GTK_CONTAINER(parent_wid_ala), ala_vbox);
    }
    // gtk_widget_show_all( parent_wid_ala);

    ala_methodtoolbar->set_sensitive();
    ala_sup_methodtoolbar->set_sensitive();
    // }


  if ( !(options & ev_mAlaOptions_Embedded)) {
    gtk_widget_show_all( parent_wid_ala);
    if ( !(x == 0 && y == 0)) {
      // Set position
      gtk_window_move( GTK_WINDOW(parent_wid_ala), x, y);
    }
  }
  else
    gtk_widget_set_size_request( ala_vbox, ala_width, ala_height);

  ala_displayed = 1;


  wow = new CoWowGtk( parent_wid_ala);

  *status = 1;
}
Exemplo n.º 8
0
XAttGtk::XAttGtk(GtkWidget* xa_parent_wid, void* xa_parent_ctx,
    pwr_sAttrRef* xa_objar, int xa_advanced_user, int* xa_sts)
    : XAtt(xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
      parent_wid(xa_parent_wid)
{
  int sts;
  pwr_tAName title;

  *xa_sts = gdh_AttrrefToName(&objar, title, sizeof(title), cdh_mNName);
  if (EVEN(*xa_sts))
    return;

  str_StrncpyCutOff(title, title, 100, 1);

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 600,
      "default-width", 420, "title", CoWowGtk::convert_utf8(title), NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon(toplevel);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_print = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Print"));
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget* file_close = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(file_close),
      gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
  gtk_widget_add_accelerator(file_close, "activate", accel_g, 'w',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget* func_changevalue = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Change _Value"));
  g_signal_connect(
      func_changevalue, "activate", G_CALLBACK(activate_change_value), this);
  gtk_widget_add_accelerator(func_changevalue, "activate", accel_g, 'q',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* func_close_changeval = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("C_lose Change Value"));
  g_signal_connect(func_close_changeval, "activate",
      G_CALLBACK(activate_close_changeval), this);
  gtk_widget_add_accelerator(func_close_changeval, "activate", accel_g, 't',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* functions_open_plc = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect(
      functions_open_plc, "activate", G_CALLBACK(activate_open_plc), this);
  gtk_widget_add_accelerator(functions_open_plc, "activate", accel_g, 'l',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_display_object = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect(functions_display_object, "activate",
      G_CALLBACK(activate_display_object), this);
  gtk_widget_add_accelerator(functions_display_object, "activate", accel_g, 'd',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_show_cross = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Show C_rossreferences"));
  g_signal_connect(
      functions_show_cross, "activate", G_CALLBACK(activate_show_cross), this);
  gtk_widget_add_accelerator(functions_show_cross, "activate", accel_g, 'r',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_open_classgraph = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Open _ClassGraph"));
  g_signal_connect(functions_open_classgraph, "activate",
      G_CALLBACK(activate_open_classgraph), this);
  gtk_widget_add_accelerator(functions_open_classgraph, "activate", accel_g,
      'g', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* func_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_changevalue);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_close_changeval);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_show_cross);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_classgraph);

  GtkWidget* functions
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // Help entry
  GtkWidget* help_help = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Help"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(help_help),
      gtk_image_new_from_stock("gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator(
      help_help, "activate", accel_g, 'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget* help
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  pane = gtk_vpaned_new();

  xattnav = new XAttNavGtk((void*)this, pane, xattnav_eType_Object, "Plant",
      &objar, xa_advanced_user, 0, &brow_widget, &sts);
  xattnav->message_cb = &message_cb;
  xattnav->change_value_cb = &change_value_cb;
  xattnav->popup_menu_cb = &xatt_popup_menu_cb;
  xattnav->is_authorized_cb = &xatt_is_authorized_cb;
  xattnav->init_cb = &init_cb;

  GtkWidget* statusbar = gtk_hbox_new(FALSE, 0);
  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);
  cmd_prompt = gtk_label_new("value > ");
  gtk_widget_set_size_request(cmd_prompt, -1, 25);
  cmd_entry = new CoWowEntryGtk(&value_recall);
  cmd_input = cmd_entry->widget();
  gtk_widget_set_size_request(cmd_input, -1, 25);
  g_signal_connect(cmd_input, "activate", G_CALLBACK(activate_cmd_input), this);

  gtk_box_pack_start(GTK_BOX(statusbar), msg_label, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 0);

  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(pane), TRUE, TRUE, 0);

  gtk_paned_pack1(GTK_PANED(pane), GTK_WIDGET(brow_widget), TRUE, TRUE);
  gtk_paned_pack2(GTK_PANED(pane), GTK_WIDGET(statusbar), FALSE, TRUE);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);

  cmd_scrolled_buffer = gtk_text_buffer_new(NULL);
  g_signal_connect_after(cmd_scrolled_buffer, "insert-text",
      G_CALLBACK(action_text_inserted), this);

  cmd_scrolledtextview = gtk_text_view_new_with_buffer(cmd_scrolled_buffer);
  GtkWidget* viewport = gtk_viewport_new(NULL, NULL);
  GtkWidget* scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), cmd_scrolledtextview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);

  cmd_scrolled_ok = gtk_button_new_with_label("Ok");
  gtk_widget_set_size_request(cmd_scrolled_ok, 70, 25);
  g_signal_connect(
      cmd_scrolled_ok, "clicked", G_CALLBACK(activate_cmd_scrolled_ok), this);
  cmd_scrolled_ca = gtk_button_new_with_label("Cancel");
  gtk_widget_set_size_request(cmd_scrolled_ca, 70, 25);
  g_signal_connect(
      cmd_scrolled_ca, "clicked", G_CALLBACK(activate_cmd_scrolled_ca), this);

  GtkWidget* hboxbuttons = gtk_hbox_new(TRUE, 40);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), cmd_scrolled_ok, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(hboxbuttons), cmd_scrolled_ca, FALSE, FALSE, 0);

  cmd_scrolledinput = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(cmd_scrolledinput), scrolledwindow, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(cmd_scrolledinput), hboxbuttons, FALSE, FALSE, 5);

  gtk_box_pack_start(GTK_BOX(statusbar), cmd_scrolledinput, TRUE, TRUE, 0);

  gtk_widget_show_all(toplevel);

  g_object_set(cmd_prompt, "visible", FALSE, NULL);
  g_object_set(cmd_input, "visible", FALSE, NULL);
  g_object_set(cmd_scrolledinput, "visible", FALSE, NULL);

  int w, h;
  gdk_drawable_get_size(pane->window, &w, &h);
  gtk_paned_set_position(GTK_PANED(pane), h - 50);

  *xa_sts = XATT__SUCCESS;
}
Exemplo n.º 9
0
CLogGtk::CLogGtk( void *clog_parent_ctx,
		  GtkWidget *clog_parent_wid,
		  const char *clog_name,
		  pwr_tStatus *status) :
  CLog( clog_parent_ctx, clog_name, status), parent_wid(clog_parent_wid), filter_form(0),
  clock_cursor(0)
{

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", 800,
					 "default-width", 1000,
					 "title", CoWowGtk::translate_utf8(clog_name),
					 NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_filter = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Filter"));
  g_signal_connect( file_filter, "activate", 
		    G_CALLBACK(activate_filter), this);

  GtkWidget *file_select_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Select File"));
  g_signal_connect( file_select_file, "activate", 
		    G_CALLBACK(activate_select_file), this);

  GtkWidget *file_next_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Next File"));
  g_signal_connect( file_next_file, "activate", 
		    G_CALLBACK(activate_next_file), this);
  gtk_widget_add_accelerator( file_next_file, "activate", accel_g,
			      'n', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *file_prev_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Previous File"));
  g_signal_connect( file_prev_file, "activate", 
		    G_CALLBACK(activate_prev_file), this);
  gtk_widget_add_accelerator( file_prev_file, "activate", accel_g,
			      'p', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *file_update = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Update"));
  g_signal_connect( file_update, "activate", 
		    G_CALLBACK(activate_update), this);
  gtk_widget_add_accelerator( file_update, "activate", accel_g,
			      'u', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), 
				 gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
  gtk_widget_add_accelerator( file_close, "activate", accel_g,
			      'w', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_filter);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_select_file);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_next_file);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_prev_file);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_update);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // View menu
  GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in), 
				 gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out), 
				 gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset), 
				 gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));


  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help on System Messages"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *help_msg = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Help on _Selected Message"));
  g_signal_connect( help_msg, "activate", 
		    G_CALLBACK(activate_helpmsg), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_msg);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  
  clognav = new CLogNavGtk( this, vbox, &clognav_widget);

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(clognav_widget), TRUE, TRUE, 0);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all( toplevel);

  wow = new CoWowGtk( toplevel);

  *status = 1;
}
Exemplo n.º 10
0
XCrrGtk::XCrrGtk( 
	GtkWidget      	*xa_parent_wid,
	void 		*xa_parent_ctx, 
	pwr_sAttrRef 	*xa_objar,
	int 		xa_advanced_user,
        int             *xa_sts) :
  XCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
  parent_wid(xa_parent_wid)
{
  int sts;
  pwr_tAName   	title;

  *xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
  if ( EVEN(*xa_sts)) return;

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
					 "default-height", 420,
					 "default-width", 600,
					 "title", CoWowGtk::convert_utf8(title),
					 NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open _Program"));
  g_signal_connect( functions_open_plc, "activate", 
		    G_CALLBACK(activate_openplc), this);
  gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
  			      'l', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);


  GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));

  // Help entry
  GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  xcrrnav = new XAttNavGtk( (void *)this, vbox, xattnav_eType_CrossRef,
			    "Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
  xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
  xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
  xcrrnav->close_cb = &xcrr_close_cb;
  xcrrnav->init_cb = &init_cb;

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  
  gtk_container_add( GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all( toplevel);

  *xa_sts = XATT__SUCCESS;
}
Exemplo n.º 11
0
WPkgGtk::WPkgGtk( 
	GtkWidget      	*wa_parent_wid,
	void 		*wa_parent_ctx)
  : WPkg(wa_parent_ctx), parent_wid(wa_parent_wid),
    clock_cursor(0)
{
  const int	window_width = 600;
  const int    	window_height = 600;
  int 		sts;
  pwr_tFileName fname;

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
			   "default-height", window_height,
			   "default-width", window_width,
			   "title", "Distributor",
			   NULL);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  GtkWidget *file_history = gtk_menu_item_new_with_mnemonic( "_History");
  g_signal_connect( file_history, "activate", 
		    G_CALLBACK(WPkgGtk::activate_history), this);

  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(WPkgGtk::activate_exit), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_history);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions Entry
  GtkWidget *functions_distribute = gtk_menu_item_new_with_mnemonic( "_Distribute");
  g_signal_connect( functions_distribute, "activate", 
		    G_CALLBACK(WPkgGtk::activate_distribute), this);
  gtk_widget_add_accelerator( functions_distribute, "activate", accel_g,
			      'd', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_createpkg = gtk_menu_item_new_with_mnemonic( "_Create Package");
  g_signal_connect( functions_createpkg, "activate", 
		    G_CALLBACK(WPkgGtk::activate_createpkg), this);

  GtkWidget *functions_deletepkg = gtk_menu_item_new_with_mnemonic( "D_elete Package");
  g_signal_connect( functions_deletepkg, "activate", 
		    G_CALLBACK(WPkgGtk::activate_deletepkg), this);

  GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_distribute);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_createpkg);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_deletepkg);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic("F_unctions");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));

  // View menu
  GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
  g_signal_connect(view_zoom_in, "activate", G_CALLBACK(WPkgGtk::activate_zoom_in), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
  g_signal_connect(view_zoom_out, "activate", G_CALLBACK(WPkgGtk::activate_zoom_out), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
  g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(WPkgGtk::activate_zoom_reset), this);

  GtkWidget *view_dmode_filediff = gtk_check_menu_item_new_with_mnemonic( "_Display File Differences");
  g_signal_connect( view_dmode_filediff, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filediff), this);

  GtkWidget *view_dmode_filetime = gtk_check_menu_item_new_with_mnemonic( "Display Files In _Time Order");
  g_signal_connect( view_dmode_filetime, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filetime), this);

  GtkWidget *view_dmode_filepath = gtk_check_menu_item_new_with_mnemonic( "Display File _Path");
  g_signal_connect( view_dmode_filepath, "activate", 
		    G_CALLBACK(WPkgGtk::activate_dmode_filepath), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filediff);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filetime);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_dmode_filepath);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic("_Help");
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(WPkgGtk::activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *tools_distribute = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/wpkg_distribute.png");
  gtk_container_add( GTK_CONTAINER(tools_distribute), 
	  gtk_image_new_from_file( fname));
  g_signal_connect(tools_distribute, "clicked", G_CALLBACK(WPkgGtk::activate_distribute), this);
  g_object_set( tools_distribute, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_distribute, "Distribute", "");

  GtkWidget *tools_zoom_in = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_in), this);
  g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_in, "Zoom in", "");

  GtkWidget *tools_zoom_out = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_out), this);
  g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_out, "Zoom out", "");

  GtkWidget *tools_zoom_reset = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(WPkgGtk::activate_zoom_reset), this);
  g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_reset, "Zoom reset", "");

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);

  utility = ((WUtility *)parent_ctx)->utype;
  wpkgnav = new WPkgNavGtk( (void *)this, vbox, "Packages",
		utility, &brow_widget, &sts);
  ((WPkgNav *)wpkgnav)->message_cb = message_cb;
  ((WPkgNav *)wpkgnav)->set_clock_cursor_cb = set_clock_cursor_cb;
  ((WPkgNav *)wpkgnav)->reset_cursor_cb = reset_cursor_cb;

  GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
  msg_label = gtk_label_new( "");

  gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 20);
  gtk_widget_show_all( statusbar);

  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 3);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all( toplevel);

  wow = new CoWowGtk( toplevel);

  if ( utility == wb_eUtility_Wtt) {
    ((Wtt *)parent_ctx)->register_utility( (void *) this,
	wb_eUtility_Distributor);
  }
}
Exemplo n.º 12
0
GeCurveGtk::GeCurveGtk( void *gc_parent_ctx, 
			GtkWidget *parent_widget,
			char *curve_name,
			char *filename,
			GeCurveData *curve_data,
			int pos_right,
			int gc_width,
			int gc_height,
			unsigned int gc_options,
			int gc_color_theme,
			void *basewidget) :
  GeCurve( gc_parent_ctx, curve_name, filename, curve_data, pos_right, 
	   gc_width, gc_height, gc_options, gc_color_theme),
  minmax_widget(0), export_widget(0), disable_timecombo_callback(0), clock_cursor(0)

{
  int	window_width = 900;
  int   window_height = 700;
  const int    	names_height = 150;
  const int    	nav_height = 120;
  pwr_tFileName fname;
  float height_scale = 1;
  int   nonav = 0;

  if ( gc_width != 0)
    window_width = gc_width;
  if ( gc_height != 0) {
    height_scale = (float)gc_height / window_height;
    window_height = gc_height;
  }

  cdh_StrncpyCutOff( title, curve_name, sizeof(title), 1);

  // Gtk
  if ( !(options & curve_mOptions_Embedded)) {
    toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					   "default-height", window_height,
					   "default-width", window_width,
					   "title", CoWowGtk::convert_utf8(title),
					   NULL);

    g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
    g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
    g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
    
    CoWowGtk::SetWindowIcon( toplevel);
  }
  else {
    toplevel = parent_widget;
  }

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  menu_add = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Add"));
  g_signal_connect( menu_add, "activate", 
		    G_CALLBACK(activate_madd), this);

  GtkWidget *file_refresh = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Refresh"));
  g_signal_connect( file_refresh, "activate", 
		    G_CALLBACK(activate_configure), this);
  gtk_widget_add_accelerator( file_refresh, "activate", accel_g, 'r', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print), 
				 gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  menu_export = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Export"));
  g_signal_connect(menu_export, "activate", G_CALLBACK(activate_export), this);

  menu_new = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_New"));
  g_signal_connect(menu_new, "activate", G_CALLBACK(activate_new), this);

  menu_save = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("S_ave"));
  g_signal_connect(menu_save, "activate", G_CALLBACK(activate_save), this);
  gtk_widget_add_accelerator( menu_save, "activate", accel_g,'s', 
			      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  menu_open = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Open"));
  g_signal_connect(menu_open, "activate", G_CALLBACK(activate_open), this);

  menu_snapshot = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Snapshot"));
  g_signal_connect(menu_snapshot, "activate", G_CALLBACK(activate_snapshot), this);
  gtk_widget_add_accelerator( menu_snapshot, "activate", accel_g,'n', 
			      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close), 
				 gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
  gtk_widget_add_accelerator( file_close, "activate", accel_g,'w', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_add);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_refresh);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_new);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_open);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_save);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_snapshot);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), menu_export);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // View menu
  GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in), 
				 gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoomin), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
			      'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out), 
				 gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoomout), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
			      'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset), 
				 gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoomreset), this);

  GtkWidget *view_background = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Background Color"));
  g_signal_connect( view_background, "activate", 
		    G_CALLBACK(activate_background), this);

  GtkWidget *view_showname = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Show Names"));
  g_signal_connect( view_showname, "activate", 
		    G_CALLBACK(activate_showname), this);
  gtk_widget_add_accelerator( view_showname, "activate", accel_g,
			      'w', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_filledcurves = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Filled Curves"));
  g_signal_connect( view_filledcurves, "activate", 
		    G_CALLBACK(activate_filledcurves), this);

  GtkWidget *view_xlimits = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_X-Axis Limits"));
  g_signal_connect( view_xlimits, "activate", 
		    G_CALLBACK(activate_xlimits), this);

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_background);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_showname);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_filledcurves);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_xlimits);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *tools_zoom_in = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoomin), this);
  g_object_set( tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_in, CoWowGtk::translate_utf8("Zoom in"), "");

  GtkWidget *tools_zoom_out = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoomout), this);
  g_object_set( tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_out, CoWowGtk::translate_utf8("Zoom out"), "");

  GtkWidget *tools_zoom_reset = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoomreset), this);
  g_object_set( tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_zoom_reset, CoWowGtk::translate_utf8("Zoom reset"), "");

  GtkWidget *tools_page_left = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_page_left.png");
  gtk_container_add( GTK_CONTAINER(tools_page_left), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_page_left, "clicked", G_CALLBACK(activate_page_left), this);
  g_object_set( tools_page_left, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_page_left, CoWowGtk::translate_utf8("Page left"), "");

  GtkWidget *tools_scroll_left = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_scroll_left.png");
  gtk_container_add( GTK_CONTAINER(tools_scroll_left), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_scroll_left, "clicked", G_CALLBACK(activate_scroll_left), this);
  g_object_set( tools_scroll_left, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_scroll_left, CoWowGtk::translate_utf8("Scroll left"), "");

  GtkWidget *tools_scroll_right = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_scroll_right.png");
  gtk_container_add( GTK_CONTAINER(tools_scroll_right), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_scroll_right, "clicked", G_CALLBACK(activate_scroll_right), this);
  g_object_set( tools_scroll_right, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_scroll_right, CoWowGtk::translate_utf8("Scroll right"), "");

  GtkWidget *tools_page_right = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_page_right.png");
  gtk_container_add( GTK_CONTAINER(tools_page_right), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_page_right, "clicked", G_CALLBACK(activate_page_right), this);
  g_object_set( tools_page_right, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_page_right, CoWowGtk::translate_utf8("Page right"), "");

  tools_snapshot = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_snapshot.png");
  gtk_container_add( GTK_CONTAINER(tools_snapshot), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_snapshot, "clicked", G_CALLBACK(activate_snapshot), this);
  g_object_set( tools_snapshot, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_snapshot, CoWowGtk::translate_utf8("Snapshot"), "");

  tools_add = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_add.png");
  gtk_container_add( GTK_CONTAINER(tools_add), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_add, "clicked", G_CALLBACK(activate_add), this);
  g_object_set( tools_add, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( tools, tools_add, CoWowGtk::translate_utf8("Add"), "");

  // Time box
  GtkToolbar *timetools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *sea_time_start_label = gtk_label_new( CoWowGtk::translate_utf8("Time"));
  gtk_widget_set_size_request( sea_time_start_label, 70, -1);
  gtk_misc_set_alignment( GTK_MISC(sea_time_start_label), 0.0, 0.5);
  gtk_toolbar_append_widget( timetools, sea_time_start_label, "", "");

  // Time option menu
  timebox_timecombo = gtk_combo_box_new_text();

  for ( int i = 0; curve_timecombo_text[i].text[0]; i++)
    gtk_combo_box_append_text( GTK_COMBO_BOX(timebox_timecombo), 
			       CoWowGtk::translate_utf8(curve_timecombo_text[i].text));

  g_signal_connect(timebox_timecombo, "changed", G_CALLBACK(activate_timecombo), this);

  gtk_toolbar_append_widget( timetools, timebox_timecombo, 0, "");
  timebox_start_time = gtk_entry_new();
  gtk_widget_set_size_request( timebox_start_time, 160, -1);
  gtk_toolbar_append_widget( timetools, timebox_start_time, "", "");

  GtkWidget *sea_time_stop_label = gtk_label_new( CoWowGtk::translate_utf8("-"));
  gtk_widget_set_size_request( sea_time_stop_label, 20, -1);
  gtk_toolbar_append_widget( timetools, sea_time_stop_label, "", "");

  timebox_stop_time = gtk_entry_new();
  gtk_widget_set_size_request( timebox_stop_time, 160, -1);
  gtk_toolbar_append_widget( timetools, timebox_stop_time, "", "");

  GtkWidget *timebox_prev_period = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_scroll_left.png");
  gtk_container_add( GTK_CONTAINER(timebox_prev_period), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_prev_period, "clicked", G_CALLBACK(activate_prev_period), this);
  g_object_set( timebox_prev_period, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( timetools, timebox_prev_period, CoWowGtk::translate_utf8("Previous period"), "");

  GtkWidget *timebox_next_period = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_scroll_right.png");
  gtk_container_add( GTK_CONTAINER(timebox_next_period), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_next_period, "clicked", G_CALLBACK(activate_next_period), this);
  g_object_set( timebox_next_period, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( timetools, timebox_next_period, CoWowGtk::translate_utf8("Next period"), "");

  GtkWidget *timebox_increase_period = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_up.png");
  gtk_container_add( GTK_CONTAINER(timebox_increase_period), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_increase_period, "clicked", G_CALLBACK(activate_increase_period), this);
  g_object_set( timebox_increase_period, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( timetools, timebox_increase_period, CoWowGtk::translate_utf8("Increase period"), "");

  GtkWidget *timebox_decrease_period = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_down.png");
  gtk_container_add( GTK_CONTAINER(timebox_decrease_period), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_decrease_period, "clicked", G_CALLBACK(activate_decrease_period), this);
  g_object_set( timebox_decrease_period, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget( timetools, timebox_decrease_period, CoWowGtk::translate_utf8("Decrease period"), "");


  GtkWidget *timebox_reload = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/ge_reload.png");
  gtk_container_add( GTK_CONTAINER(timebox_reload), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_reload, "clicked", G_CALLBACK(activate_reload), this);
  g_object_set( timebox_reload, "can-focus", FALSE, NULL);
  // gtk_toolbar_append_widget( timetools, timebox_reload, CoWowGtk::translate_utf8("Update"), "");

  GtkWidget *timebox_add = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_add.png");
  gtk_container_add( GTK_CONTAINER(timebox_add), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_add, "clicked", G_CALLBACK(activate_add), this);
  g_object_set( timebox_add, "can-focus", FALSE, NULL);
  // gtk_toolbar_append_widget( timetools, timebox_add, CoWowGtk::translate_utf8("Add curve item"), "");

  GtkWidget *timebox_remove = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_remove.png");
  gtk_container_add( GTK_CONTAINER(timebox_remove), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(timebox_remove, "clicked", G_CALLBACK(activate_remove), this);
  g_object_set( timebox_remove, "can-focus", FALSE, NULL);
  // gtk_toolbar_append_widget( timetools, timebox_remove, CoWowGtk::translate_utf8("Remove selected curve"), "");


  GtkToolbar *curvebuttonbox = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);
  //GtkWidget *curvebuttonbox = gtk_hbox_new( FALSE, 0);
  gtk_toolbar_append_widget( curvebuttonbox, timebox_reload, CoWowGtk::translate_utf8("Update curve"), "");
  gtk_toolbar_append_widget( curvebuttonbox, timebox_add, CoWowGtk::translate_utf8("Add curve item"), "");

  sea_timebox = gtk_hbox_new( FALSE, 0);
  //  gtk_box_pack_start( GTK_BOX(sea_timebox), sea_time_start_label, FALSE, FALSE, 0);
  //  gtk_box_pack_start( GTK_BOX(sea_timebox), timebox_timecombo, FALSE, FALSE, 10);
  //  gtk_box_pack_start( GTK_BOX(sea_timebox), timebox_start_time, FALSE, FALSE, 0);
  //  gtk_box_pack_start( GTK_BOX(sea_timebox), sea_time_stop_label, FALSE, FALSE, 0);
  //  gtk_box_pack_start( GTK_BOX(sea_timebox), timebox_stop_time, FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(sea_timebox), GTK_WIDGET(timetools), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(sea_timebox), gtk_hseparator_new(), FALSE, FALSE, 10);
  gtk_box_pack_start( GTK_BOX(sea_timebox), GTK_WIDGET(curvebuttonbox), FALSE, FALSE, 0);

  GtkWidget *w;
    grownames_main_widget = scrolledgrowwidgetgtk_new( init_grownames_cb, this, &w);

  if ( nonav)
    growcurve_main_widget = scrolledcurvewidgetgtk_new( init_growcurve_cb, this, &w);
  else
    growcurve_main_widget = curvewidgetgtk_new( init_growcurve_cb, this);

  growaxis_main_widget = growwidgetgtk_new( init_growaxis_cb, this);

  if (!nonav)
    nav_widget = curvenavwidgetgtk_new( growcurve_main_widget);

  GtkWidget *hbox = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(hbox), growaxis_main_widget, FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(hbox), growcurve_main_widget, TRUE, TRUE, 0);
  gtk_widget_show_all( hbox);

  GtkWidget *vpaned1 = gtk_vpaned_new();
  GtkWidget *vpaned2 = gtk_vpaned_new();

  gtk_paned_add1( GTK_PANED(vpaned1), grownames_main_widget);
  gtk_paned_add2( GTK_PANED(vpaned1), vpaned2);
  gtk_widget_show_all( vpaned1);

  gtk_paned_pack1( GTK_PANED(vpaned2), hbox, TRUE, TRUE);
  if ( !nonav)
    gtk_paned_pack2( GTK_PANED(vpaned2), nav_widget, FALSE, TRUE);
  gtk_widget_show_all( vpaned2);

  GtkWidget *tools_box = gtk_hbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(tools_box), GTK_WIDGET(tools), FALSE, FALSE, 0);
  //  gtk_box_pack_start( GTK_BOX(tools_box), GTK_WIDGET(sea_timebox), FALSE, FALSE, 0);

  vbox = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools_box), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(sea_timebox), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(vpaned1), TRUE, TRUE, 0);

  if ( !(options & curve_mOptions_Embedded)) {
    gtk_container_add( GTK_CONTAINER(toplevel), vbox);

    gtk_widget_show_all( toplevel);
  }
  else
    gtk_widget_set_size_request( vbox, window_width, window_height);

  gtk_paned_set_position( GTK_PANED(vpaned1), names_height * height_scale);
  gtk_paned_set_position( GTK_PANED(vpaned2), (window_height - names_height - nav_height - 50) * height_scale);
  g_object_set( sea_timebox, "visible", FALSE, NULL);
  g_object_set( menu_new, "visible", FALSE, NULL);
  g_object_set( menu_save, "visible", FALSE, NULL);
  g_object_set( menu_open, "visible", FALSE, NULL);
  g_object_set( menu_snapshot, "visible", FALSE, NULL);
  g_object_set( menu_export, "visible", FALSE, NULL);
  g_object_set( tools_snapshot, "visible", FALSE, NULL);
  g_object_set( tools_add, "visible", FALSE, NULL);

  wow = new CoWowGtk( toplevel);

  gtk_combo_box_set_active( GTK_COMBO_BOX(timebox_timecombo), 2);

  if ( !(options & curve_mOptions_Embedded)) {
    if ( options & curve_mOptions_FullScreen)
      gtk_window_fullscreen( GTK_WINDOW(toplevel));
    else if ( options & curve_mOptions_Maximize)
      gtk_window_maximize( GTK_WINDOW(toplevel)); // TODO
    else if ( options & curve_mOptions_FullMaximize)
      gtk_window_maximize( GTK_WINDOW(toplevel));
    else if ( options & curve_mOptions_Iconify)
      gtk_window_iconify( GTK_WINDOW(toplevel));
    else if ( options & curve_mOptions_Invisible)
      g_object_set( toplevel, "visible", FALSE, NULL);

    if ( basewidget)
      gtk_window_set_transient_for(GTK_WINDOW(toplevel), GTK_WINDOW(basewidget));

  }  
}
Exemplo n.º 13
0
/**
 * \brief Create all the skel or container windows for modules but ui.
 *
 * ui, is only part of skel, all the content is filled later.
 *
 * content type:
 *      page, trigger, hbar, vbar
 *
 * main window.             p.ui.ui.window.main
 * optn window.             p.ui.ui.window.optn
 * info window.             p.ui.ui.window.info
 * media window             p.ui.ui.window.media
 */
static void ui_create_ui(KIM * im)
{
    char xmlpath[1024];
    sprintf(xmlpath, "%s\\ui\\main.glade", kim_getstr(im, "s.env.path.moduleDir", knil));
    kstr_subs(xmlpath, '\\', kvfs_path_sep());

    GladeXML *gxml = glade_xml_new(xmlpath, NULL, NULL);
    kim_addptr(im, "p.ui.ui.glade", (kvoid *) gxml, RF_AUTOSET, knil, knil);

    GtkWidget *window_main = glade_xml_get_widget(gxml, "window_main");
    kim_addptr(im, "p.ui.ui.window.main", (kvoid *) window_main, RF_AUTOSET, knil, knil);
    klog(("window_main: %s\n", GTK_OBJECT_TYPE_NAME(window_main)));

    GtkWidget *vbox_main = glade_xml_get_widget(gxml, "winmain_vbox_main");
    klog(("vbox_main: %s\n", GTK_OBJECT_TYPE_NAME(vbox_main)));

    gtk_drag_dest_set(vbox_main, GTK_DEST_DEFAULT_ALL, target_table, n_targets, /* no rootwin */
                      GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
    g_signal_connect(vbox_main, "drag_drop", G_CALLBACK(target_drag_drop), vbox_main);

    g_signal_connect(vbox_main, "drag_data_received", G_CALLBACK(target_drag_data_received), NULL);


    if (0) {
        GtkWidget *button;
        button = gtk_button_new_with_label("xxyyyx");
        //button = gtk_viewport_new(NULL, NULL);//"GTK_WINDOW_TOPLEVEL");
        gtk_box_pack_start(GTK_BOX(vbox_main), button, TRUE, FALSE, 0);

        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
    }

    GtkWidget *window_info = glade_xml_get_widget(gxml, "window_info");
    kim_addptr(im, "p.ui.ui.window.info", (kvoid *) window_info, RF_AUTOSET, knil, knil);

    GtkWidget *window_media = glade_xml_get_widget(gxml, "window_media");
    kim_addptr(im, "p.ui.ui.window.media", (kvoid *) window_media, RF_AUTOSET, knil, knil);

    // gtk_box_pack_start(GTK_BOX(vbox_main), window_media, TRUE, FALSE, 0);

    GtkWidget *window_pref = glade_xml_get_widget(gxml, "window_pref");
    kim_addptr(im, "p.ui.ui.window.optn", (kvoid *) window_pref, RF_AUTOSET, knil, knil);
    gtk_widget_show(window_pref);

    if (0) {
        GtkWidget *button;
        button = gtk_button_new_with_label("xxyyyx");
        gtk_box_pack_start(GTK_BOX(vbox_main), button, TRUE, TRUE, 0);
        kim_addptr(im, "p.ui.ui.window.optn", (kvoid *) button, RF_AUTOSET, knil, knil);
    }

    GtkWidget *window_tool = glade_xml_get_widget(gxml, "window_tool");
    kim_addptr(im, "p.ui.ui.window.tool", (kvoid *) window_tool, RF_AUTOSET, knil, knil);

    GtkWidget *window_tool_pool = glade_xml_get_widget(gxml, "wintool_viewport_tool_pool");
    kim_addptr(im, "p.ui.ui.window.tool_pool", (kvoid *) window_tool_pool, RF_AUTOSET, knil, knil);

    GtkWidget *window_layout_tool_pool = glade_xml_get_widget(gxml, "wintool_viewport_layout_tool_pool");
    kim_addptr(im, "p.ui.ui.window.layout_tool_pool", (kvoid *) window_layout_tool_pool, RF_AUTOSET, knil, knil);

    glade_xml_signal_autoconnect(gxml);

    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_about_activate",
                                  G_CALLBACK(on_winmain_menu_item_about_activate), NULL);
    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_tool_activate",
                                  G_CALLBACK(on_winmain_menu_item_tool_activate), NULL);
    glade_xml_signal_connect_data(gxml, "on_winmain_menu_item_pref_activate",
                                  G_CALLBACK(on_winmain_menu_item_pref_activate), NULL);
}
Exemplo n.º 14
0
static void fill_tool_window()
{
    GtkWidget *window_tool_pool = (GtkWidget *) kim_getptr(__g_im, "p.ui.ui.window.tool_pool", knil);
    GtkWidget *window_layout_tool_pool = (GtkWidget *) kim_getptr(__g_im, "p.ui.ui.window.layout_tool_pool", knil);
    window_tool_pool = window_layout_tool_pool;

    GtkWidget *tool_box;
    GtkWidget *button;

    char label[22];
    gint i;
    GList *l;
    ToolEntry *te;

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);

    mk_htoolbar(ktrue);
    mk_button_play(ktrue);
    mk_button_play(ktrue);
    mk_button_play(ktrue);
    mk_htoolbar(ktrue);
    mk_htoolbar(ktrue);

    gtk_widget_set_size_request(GTK_WIDGET(window_tool_pool), 200, 200);

    tool_box = glade_palette_box_new();

    /* FIXME: set border other than 0 can make layout mess some time */
    gtk_container_set_border_width(GTK_CONTAINER(tool_box), 0);

    for (l = __g_tool_list; l; l = l->next) {
        te = (ToolEntry *) l->data;
        button = create_tool_widget2(te);

        printf("fill_tool_window: button: %x\n", button);

#if 10                          /* TODO */
        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
#endif

        g_signal_connect(button, "drag_data_get", G_CALLBACK(source_drag_data_get), te);

        gtk_container_add(GTK_CONTAINER(tool_box), button);
    }

#if 0
    for (i = 0; i < 15; i++) {
        sprintf(label, "NIU-NIU-NIU:%X\n", i);
        button = gtk_button_new_with_label(label);
        button = create_tool_widget();

#if 10                          /* TODO */
        gtk_drag_source_set(button, GdkModifierType(GDK_BUTTON1_MASK | GDK_BUTTON3_MASK),
                            target_table, n_targets, GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
#endif

        gtk_container_add(GTK_CONTAINER(tool_box), button);
    }
#endif

    gtk_container_add(GTK_CONTAINER(window_tool_pool), tool_box);

    gtk_widget_show_all(GTK_WIDGET(window_tool_pool));
}
Exemplo n.º 15
0
WAttTextGtk::WAttTextGtk(GtkWidget* wa_parent_wid, void* wa_parent_ctx,
    ldh_tSesContext wa_ldhses, pwr_sAttrRef wa_aref, int wa_editmode,
    pwr_tStatus* status)
    : WAttText(wa_parent_ctx, wa_ldhses, wa_aref, wa_editmode, status),
      parent_wid(wa_parent_wid), toplevel(0), init(1)
{
  int sts;
  int size;
  char* namep;

  if (EVEN(*status))
    return;

  sts = ldh_AttrRefToName(ldhses, &aref, ldh_eName_Hierarchy, &namep, &size);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 700,
      "default-width", 800, "title", CoWowGtk::convert_utf8(namep), NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);

  CoWowGtk::SetWindowIcon(toplevel);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_close
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);

  GtkWidget* file_save
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_SAVE, accel_g);
  g_signal_connect(file_save, "activate", G_CALLBACK(activate_save), this);

  GtkWidget* file_saveandclose
      = gtk_menu_item_new_with_mnemonic("S_ave and close");
  g_signal_connect(
      file_saveandclose, "activate", G_CALLBACK(activate_saveandclose), this);
  gtk_widget_add_accelerator(file_saveandclose, "activate", accel_g, 't',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_saveandclose);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Edit entry
  GtkWidget* edit_copy
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_COPY, accel_g);
  g_signal_connect(edit_copy, "activate", G_CALLBACK(activate_copy), this);

  GtkWidget* edit_cut
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CUT, accel_g);
  g_signal_connect(edit_cut, "activate", G_CALLBACK(activate_cut), this);

  GtkWidget* edit_paste
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_PASTE, accel_g);
  g_signal_connect(edit_paste, "activate", G_CALLBACK(activate_paste), this);

  GtkMenu* edit_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_copy);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_cut);
  gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_paste);

  GtkWidget* edit = gtk_menu_item_new_with_mnemonic("_Edit");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), edit);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(edit), GTK_WIDGET(edit_menu));

  // Help entry
  GtkWidget* help_help
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);

  GtkWidget* help = gtk_menu_item_new_with_mnemonic("_Help");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  if (((WUtility*)parent_ctx)->utype == wb_eUtility_WNav)
    parent_ctx = ((WNav*)parent_ctx)->parent_ctx;
  utility = ((WUtility*)parent_ctx)->utype;

  textbuffer = gtk_text_buffer_new(NULL);
  g_signal_connect_after(
      textbuffer, "insert-text", G_CALLBACK(action_text_inserted), this);
  g_signal_connect_after(
      textbuffer, "changed", G_CALLBACK(action_text_changed), this);

  textview = gtk_text_view_new_with_buffer(textbuffer);
  GtkWidget* viewport = gtk_viewport_new(NULL, NULL);
  GtkWidget* scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_container_add(GTK_CONTAINER(viewport), textview);
  gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);

  button_ok = gtk_button_new_with_label("Ok");
  gtk_widget_set_size_request(button_ok, 70, 25);
  g_signal_connect(button_ok, "clicked", G_CALLBACK(activate_ok), this);
  button_apply = gtk_button_new_with_label("Apply");
  gtk_widget_set_size_request(button_apply, 70, 25);
  g_signal_connect(button_apply, "clicked", G_CALLBACK(activate_apply), this);
  button_cancel = gtk_button_new_with_label("Cancel");
  gtk_widget_set_size_request(button_cancel, 70, 25);
  g_signal_connect(button_cancel, "clicked", G_CALLBACK(activate_cancel), this);

  GtkWidget* hboxbuttons = gtk_hbox_new(TRUE, 40);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), button_ok, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hboxbuttons), button_apply, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(hboxbuttons), button_cancel, FALSE, FALSE, 0);

  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), msg_label, FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all(toplevel);

  if (utility == wb_eUtility_Wtt) {
    ((Wtt*)parent_ctx)
        ->register_utility((void*)this, wb_eUtility_AttrTextEditor);
  }

  char* value;
  ldh_sAttrRefInfo ainfo;

  sts = ldh_GetAttrRefInfo(ldhses, &aref, &ainfo);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  char* s = strchr(namep, '.');
  if (!s)
    return;

  strncpy(aname, s + 1, sizeof(aname));

  sts = ldh_GetObjectPar(
      ldhses, aref.Objid, "DevBody", aname, (char**)&value, &size);
  if (EVEN(sts)) {
    *status = sts;
    return;
  }

  input_max_length = ainfo.size - 1;

  GtkTextIter start_iter, end_iter;
  gtk_text_buffer_get_start_iter(textbuffer, &start_iter);
  gtk_text_buffer_get_end_iter(textbuffer, &end_iter);
  gtk_text_buffer_delete(textbuffer, &start_iter, &end_iter);

  gtk_text_buffer_get_start_iter(textbuffer, &start_iter);

  char* textutf8 = g_convert(value, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
  gtk_text_buffer_insert(textbuffer, &start_iter, textutf8, -1);
  g_free(textutf8);

  free(value);

  if (!editmode) {
    gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), FALSE);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview), FALSE);
  }

  wow = new CoWowGtk(toplevel);
  init = 0;
}
Exemplo n.º 16
0
XttTblGtk::XttTblGtk(GtkWidget* a_parent_wid, void* a_parent_ctx,
    sevcli_tCtx a_sevcli, sevcli_sHistItem* itemlist, int item_cnt)
    : XttTbl(a_parent_ctx, a_sevcli), parent_wid(a_parent_wid)
{
  int sts;
  pwr_tFileName fname;

  toplevel = (GtkWidget*)g_object_new(GTK_TYPE_WINDOW, "default-height", 700,
      "default-width", 500, "title", "SevXtt Navigator", NULL);

  g_signal_connect(toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect(toplevel, "destroy", G_CALLBACK(destroy_event), this);
  g_signal_connect(
      toplevel, "focus-in-event", G_CALLBACK(xtttbl_focus_in_event), this);

  CoWowGtk::SetWindowIcon(toplevel);

  GtkWidget* vbox = gtk_vbox_new(FALSE, 0);

  // Menu
  // Accelerators
  GtkAccelGroup* accel_g
      = (GtkAccelGroup*)g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar* menu_bar = (GtkMenuBar*)g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File entry
  GtkWidget* file_print = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Print"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(file_print),
      gtk_image_new_from_stock("gtk-print", GTK_ICON_SIZE_MENU));
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);

  GtkWidget* file_login
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Login"));
  g_signal_connect(file_login, "activate", G_CALLBACK(activate_login), this);

  GtkWidget* file_logout
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Log_Out"));
  g_signal_connect(file_logout, "activate", G_CALLBACK(activate_logout), this);

  GtkWidget* file_close
      = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_close), this);

  GtkMenu* file_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_login);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_logout);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget* file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions entry
  GtkWidget* functions_opensevhist = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Open Process History"));
  g_signal_connect(functions_opensevhist, "activate",
      G_CALLBACK(activate_opensevhist), this);
  gtk_widget_add_accelerator(functions_opensevhist, "activate", accel_g, 'g',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_command
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Co_mmand"));
  g_signal_connect(
      functions_command, "activate", G_CALLBACK(activate_command), this);
  gtk_widget_add_accelerator(functions_command, "activate", accel_g, 'b',
      GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);

  GtkWidget* functions_delete_item = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Delete Item"));
  g_signal_connect(functions_delete_item, "activate",
      G_CALLBACK(activate_delete_item), this);

  GtkMenu* functions_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_opensevhist);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_command);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_delete_item);

  GtkWidget* functions
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(
      GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));

  // View menu
  GtkWidget* view_tree_layout = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Tree Layout"));
  g_signal_connect(
      view_tree_layout, "activate", G_CALLBACK(activate_tree_layout), this);

  GtkWidget* view_list_layout = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_List Layout"));
  g_signal_connect(
      view_list_layout, "activate", G_CALLBACK(activate_list_layout), this);

  GtkWidget* view_zoom_in = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _In"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_in),
      gtk_image_new_from_stock("gtk-zoom-in", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
  gtk_widget_add_accelerator(view_zoom_in, "activate", accel_g, 'i',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* view_zoom_out = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _Out"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_out),
      gtk_image_new_from_stock("gtk-zoom-out", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
  gtk_widget_add_accelerator(view_zoom_out, "activate", accel_g, 'o',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("Zoom _Reset"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(view_zoom_reset),
      gtk_image_new_from_stock("gtk-zoom-100", GTK_ICON_SIZE_MENU));
  g_signal_connect(
      view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);

  GtkMenu* view_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_tree_layout);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_list_layout);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);

  GtkWidget* view
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Help entry
  GtkWidget* help_overview = gtk_image_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_Overview"));
  gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(help_overview),
      gtk_image_new_from_stock("gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_overview, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator(help_overview, "activate", accel_g, 'h',
      GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget* help_project
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Project"));
  g_signal_connect(
      help_project, "activate", G_CALLBACK(activate_help_project), this);

  GtkWidget* help_proview = gtk_menu_item_new_with_mnemonic(
      CoWowGtk::translate_utf8("_About Proview"));
  g_signal_connect(
      help_proview, "activate", G_CALLBACK(activate_help_proview), this);

  GtkMenu* help_menu = (GtkMenu*)g_object_new(GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_overview);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_project);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_proview);

  GtkWidget* help
      = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar* tools = (GtkToolbar*)g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget* tools_opensevhist = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_meth_trend.png");
  gtk_container_add(
      GTK_CONTAINER(tools_opensevhist), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_opensevhist, "clicked", G_CALLBACK(activate_opensevhist), this);
  g_object_set(tools_opensevhist, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(tools, tools_opensevhist,
      CoWowGtk::translate_utf8("Open history item"), "");

  GtkWidget* tools_zoom_in = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_in), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_in, "clicked", G_CALLBACK(activate_zoom_in), this);
  g_object_set(tools_zoom_in, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_in, CoWowGtk::translate_utf8("Zoom in"), "");

  GtkWidget* tools_zoom_out = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_out), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_out, "clicked", G_CALLBACK(activate_zoom_out), this);
  g_object_set(tools_zoom_out, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_out, CoWowGtk::translate_utf8("Zoom out"), "");

  GtkWidget* tools_zoom_reset = gtk_button_new();
  dcli_translate_filename(fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add(
      GTK_CONTAINER(tools_zoom_reset), gtk_image_new_from_file(fname));
  g_signal_connect(
      tools_zoom_reset, "clicked", G_CALLBACK(activate_zoom_reset), this);
  g_object_set(tools_zoom_reset, "can-focus", FALSE, NULL);
  gtk_toolbar_append_widget(
      tools, tools_zoom_reset, CoWowGtk::translate_utf8("Zoom reset"), "");

  // Statusbar and cmd input
  GtkWidget* statusbar = gtk_hbox_new(FALSE, 0);
  msg_label = gtk_label_new("");
  gtk_widget_set_size_request(msg_label, -1, 25);
  cmd_prompt = gtk_label_new("xtt > ");
  gtk_widget_set_size_request(cmd_prompt, -1, 25);

  cmd_recall = new CoWowRecall();
  cmd_entry = new CoWowEntryGtk(cmd_recall);
  cmd_input = cmd_entry->widget();
  gtk_widget_set_size_request(cmd_input, -1, 25);
  g_signal_connect(
      cmd_input, "activate", G_CALLBACK(valchanged_cmd_input), this);

  gtk_box_pack_start(GTK_BOX(statusbar), msg_label, FALSE, FALSE, 20);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 20);
  gtk_box_pack_start(GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 20);
  gtk_widget_show_all(statusbar);

  tblnav
      = new TblNavGtk(this, toplevel, itemlist, item_cnt, &brow_widget, &sts);
  tblnav->message_cb = &XttTbl::message;
  tblnav->is_authorized_cb = &XttTbl::is_authorized;
  tblnav->command_cb = &XttTbl::command_cb;

  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 3);

  gtk_container_add(GTK_CONTAINER(toplevel), vbox);

  gtk_widget_show_all(toplevel);

  g_object_set(cmd_prompt, "visible", FALSE, NULL);
  g_object_set(cmd_input, "visible", FALSE, NULL);

  // Create help window
  CoXHelp* xhelp = new CoXHelpGtk(toplevel, this, xhelp_eUtility_Xtt, &sts);
  CoXHelp::set_default(xhelp);

  wow = new CoWowGtk(toplevel);

  if (!is_authorized(pwr_mAccess_AllSev, 0))
    open_login();

  if (!quiet) {
    if (cologin)
      // Set login window as parent to warranty as focus is left to parent.
      ((CoWowGtk*)wow)->SetParent(((CoLoginGtk*)cologin)->widgets.toplevel);

    wow->DisplayWarranty();

    if (cologin)
      ((CoWowGtk*)wow)->SetParent(toplevel);
  }
}
Exemplo n.º 17
0
RtTraceGtk::RtTraceGtk( void *tr_parent_ctx, GtkWidget *tr_parent_wid, pwr_tObjid tr_objid,
			pwr_tStatus *status) :
  RtTrace( tr_parent_ctx, tr_objid, status), parent_wid(tr_parent_wid), toplevel(0), nav_shell(0)
{

  const int	window_width = 900;
  const int    	window_height = 800;
  const int    	nav_width = 180;
  pwr_tStatus 	sts;
  pwr_tObjid	window_objid;
  pwr_tClassId	cid;
  char   	title[220];
  pwr_tOName   	hostname;
  pwr_tOName   	plcconnect;
  pwr_tFileName fname;

  sts = gdh_ObjidToName( tr_objid, name, sizeof(name), cdh_mNName); 
  if (EVEN(sts)) {
    *status = sts;
    return;
  }
  strcpy( title, "Trace ");
  strcat( title, name);

  /* Find plcwindow */
  sts = gdh_GetObjectClass( tr_objid, &cid);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  if ( !(cid == pwr_cClass_windowplc ||
         cid == pwr_cClass_windowcond ||
         cid == pwr_cClass_windoworderact ||
         cid == pwr_cClass_windowsubstep )) {
    sts = gdh_GetChild( tr_objid, &window_objid);
    if ( EVEN(sts)) {
      *status = sts;
      return;
    }
  }
  else
    window_objid = tr_objid; 

  sts = gdh_GetObjectClass( window_objid, &cid);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  if ( !(cid == pwr_cClass_windowplc ||
         cid == pwr_cClass_windowcond ||
         cid == pwr_cClass_windoworderact ||
         cid == pwr_cClass_windowsubstep )) {
    *status = 0;
    return;
  }

  sts = get_filename( window_objid, filename, &m_has_host, hostname, 
		      plcconnect);
  if ( EVEN(sts)) {
    *status = sts;
    return;
  }

  /* Create object context */
  objid = window_objid;
  if ( m_has_host) {
    strcpy( m_hostname, hostname);
    strcpy( m_plcconnect, plcconnect);
  }

  char *titleutf8 = g_convert( title, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);

  // Gtk
  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", window_height,
					 "default-width", window_width,
					 "title", titleutf8,
					 NULL);
  g_free( titleutf8);

  g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
  g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);

  CoWowGtk::SetWindowIcon( toplevel);

  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  // Submenu Print
  GtkWidget *file_print = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
  g_signal_connect( file_print, "activate", 
		    G_CALLBACK(activate_print), this);

  GtkWidget *file_print_select = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Print _Selected Documents"));
  g_signal_connect( file_print_select, "activate", 
		    G_CALLBACK(activate_printselect), this);

  GtkWidget *file_savetrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Save _Trace"));
  g_signal_connect( file_savetrace, "activate", 
		    G_CALLBACK(activate_savetrace), this);

  GtkWidget *file_restoretrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Restore Trace"));
  g_signal_connect( file_restoretrace, "activate", 
		    G_CALLBACK(activate_restoretrace), this);

  GtkWidget *file_cleartrace = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("C_lear Trace"));
  g_signal_connect( file_cleartrace, "activate", 
		    G_CALLBACK(activate_cleartrace), this);

  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(activate_close), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print_select);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_savetrace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_restoretrace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_cleartrace);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions Entry
  GtkWidget *functions_open_object = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Open Object"));
  g_signal_connect( functions_open_object, "activate", 
		    G_CALLBACK(activate_open_object), this);
  gtk_widget_add_accelerator( functions_open_object, "activate", accel_g,
  			      'a', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_open_subwindow = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open S_ubwindow"));
  g_signal_connect( functions_open_subwindow, "activate", 
		    G_CALLBACK(activate_open_subwindow), this);
  gtk_widget_add_accelerator( functions_open_subwindow, "activate", accel_g,
  			      'l', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Display object in Navigator"));
  g_signal_connect( functions_display_object, "activate", 
		    G_CALLBACK(activate_display_object), this);
  gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
  			      'd', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_show_cross = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Show Crossreferences"));
  g_signal_connect( functions_show_cross, "activate", 
		    G_CALLBACK(activate_show_cross), this);
  gtk_widget_add_accelerator( functions_show_cross, "activate", accel_g,
  			      'r', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_open_classgraph = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Open ObjectGraph"));
  g_signal_connect( functions_open_classgraph, "activate", 
		    G_CALLBACK(activate_open_classgraph), this);
  gtk_widget_add_accelerator( functions_open_classgraph, "activate", accel_g,
  			      'g', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *functions_collect_insert = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Collect Insert"));
  g_signal_connect( functions_collect_insert, "activate", 
		    G_CALLBACK(activate_collect_insert), this);
  gtk_widget_add_accelerator( functions_collect_insert, "activate", accel_g,
  			      'v', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_subwindow);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_display_object);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_show_cross);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_open_classgraph);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_collect_insert);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));


  // View Entry

  GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
  g_signal_connect( view_zoom_in, "activate", 
		    G_CALLBACK(activate_zoomin), this);
  gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
  			      'i', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
  g_signal_connect( view_zoom_out, "activate", 
		    G_CALLBACK(activate_zoomout), this);
  gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
  			      'o', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
  g_signal_connect( view_zoom_reset, "activate", 
		    G_CALLBACK(activate_zoomreset), this);
  gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
  			      'b', GdkModifierType(GDK_CONTROL_MASK), 
  			      GTK_ACCEL_VISIBLE);

  // Submenu ScanTime
  GSList *view_sc_group = NULL;
  GtkWidget *view_scantime1 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.50 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime1, "activate", 
		    G_CALLBACK(activate_scantime1), this);

  GtkWidget *view_scantime2 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.20 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime2, "activate", 
		    G_CALLBACK(activate_scantime2), this);

  GtkWidget *view_scantime3 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.10 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime3, "activate", 
		    G_CALLBACK(activate_scantime3), this);

  GtkWidget *view_scantime4 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.05 s");
  view_sc_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(view_scantime1));
  g_signal_connect( view_scantime4, "activate", 
		    G_CALLBACK(activate_scantime4), this);

  GtkWidget *view_scantime5 = gtk_radio_menu_item_new_with_mnemonic( view_sc_group, 
									"0.02 s");
  g_signal_connect( view_scantime5, "activate", 
		    G_CALLBACK(activate_scantime5), this);

  GtkWidget *view_sc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_ScanTime"));
  GtkMenu *view_sc_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime1);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime2);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime3);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime4);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_sc_menu), view_scantime5);

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view_sc),
			    GTK_WIDGET(view_sc_menu));

  GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
  gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_sc);

  GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));

  // Mode entry
  GSList *mode_group = NULL;
  GtkWidget *mode_view = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("V_iew"));
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(mode_view));
  g_signal_connect( mode_view, "activate", 
		    G_CALLBACK(activate_view), this);

  GtkWidget *mode_trace = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("_Trace"));
  mode_group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(mode_trace));
  g_signal_connect( mode_trace, "activate", 
		    G_CALLBACK(activate_trace), this);

  GtkWidget *mode_simulate = gtk_radio_menu_item_new_with_mnemonic( mode_group, CoWowGtk::translate_utf8("_Simulate"));
  gtk_widget_add_accelerator( mode_simulate, "activate", accel_g,
  			      's', GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK), 
  			      GTK_ACCEL_VISIBLE);
  g_signal_connect( mode_simulate, "activate", 
		    G_CALLBACK(activate_simulate), this);

  GtkMenu *mode_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_view);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_trace);
  gtk_menu_shell_append(GTK_MENU_SHELL(mode_menu), mode_simulate);

  GtkWidget *mode = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Mode"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), mode);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(mode), GTK_WIDGET(mode_menu));

  // Menu Help
  GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _Trace"));
  gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help), 
				 gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
  g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
  gtk_widget_add_accelerator( help_help, "activate", accel_g,
			      'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

  GtkWidget *help_plcpgm = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _PlcPgm"));
  g_signal_connect( help_plcpgm, "activate", 
		    G_CALLBACK(activate_helpplc), this);

  GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
  gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_plcpgm);

  GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));

  // Toolbar
  GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);

  GtkWidget *tools_display_object = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_navigator.png");
  gtk_container_add( GTK_CONTAINER(tools_display_object), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_display_object, "clicked", G_CALLBACK(activate_display_object), this);
  gtk_toolbar_append_widget( tools, tools_display_object, "Display object in Navigator", "");
  
  GtkWidget *tools_show_cross = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_crossref.png");
  gtk_container_add( GTK_CONTAINER(tools_show_cross), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_show_cross, "clicked", G_CALLBACK(activate_show_cross), this);
  gtk_toolbar_append_widget( tools, tools_show_cross, "Show Crossreferences", "");
  
  GtkWidget *tools_zoom_in = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_in), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoomin), this);
  gtk_toolbar_append_widget( tools, tools_zoom_in, "Zoom in", "");

  GtkWidget *tools_zoom_out = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_out.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_out), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoomout), this);
  gtk_toolbar_append_widget( tools, tools_zoom_out, "Zoom out", "");

  GtkWidget *tools_zoom_reset = gtk_button_new();
  dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_reset.png");
  gtk_container_add( GTK_CONTAINER(tools_zoom_reset), 
		     gtk_image_new_from_file( fname));
  g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoomreset), this);
  gtk_toolbar_append_widget( tools, tools_zoom_reset, "Zoom reset", "");

  // Flow widget
  GtkWidget *flow_scrolled = scrolledflowwidgetgtk_new( init_flow, 
							this, &flow_widget);
  gtk_widget_show_all(flow_widget);

  nav_widget = flownavwidgetgtk_new( flow_widget);

  GtkWidget *paned = gtk_hpaned_new();
  gtk_paned_pack1( GTK_PANED(paned), flow_scrolled, TRUE, TRUE);
  gtk_paned_pack2( GTK_PANED(paned), nav_widget, FALSE, TRUE);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(paned), TRUE, TRUE, 0);

  gtk_container_add( GTK_CONTAINER(toplevel), vbox);
  gtk_widget_show_all( toplevel);

  gtk_paned_set_position( GTK_PANED(paned), window_width - nav_width);

#if 0
  // Navigator window
  nav_shell = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					  "default-height", 200,
					  "default-width", 200,
					  "title", "Navigator",
					  NULL);
  g_signal_connect( nav_shell, "delete_event", G_CALLBACK(nav_delete_event), this);

  nav_widget = flownavwidgetgtk_new( flow_widget);
  gtk_container_add( GTK_CONTAINER(nav_shell), nav_widget);
  gtk_widget_show_all( nav_shell);
#endif

  wow = new CoWowGtk( toplevel);
  trace_timerid = wow->timer_new();

  viewsetup();
  flow_Open( flow_ctx, filename);

  gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( mode_trace), TRUE);
  gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( view_scantime1), TRUE);

  //trasetup();
  //trace_start();

#if defined OS_LINUX
  {
    struct stat info;

    if ( stat( filename, &info) != -1)
      version = info.st_ctime;    
  }
#endif

  // Check version
  unsigned int flow_version;
  pwr_tUInt32 window_version;
  pwr_tAName aname;

  flow_GetCtxUserVersion( flow_ctx, &flow_version);

  strcpy( aname, name);
  strcat( aname, ".Version");

  sts = gdh_GetObjectInfo( aname, &window_version, sizeof(window_version));
  if ( EVEN(sts)) return;

  if ( flow_version > window_version)
    wow->DisplayError( "Version mismatch", "Trace file is newer than database version");
  else if ( flow_version < window_version)
    wow->DisplayError( "Version mismatch", "Trace file is older than database version");
}
Exemplo n.º 18
0
WVselGtk::WVselGtk (
  pwr_tStatus   *status,
  void		*wv_parent_ctx,
  GtkWidget	*wv_parent_wid,
  const char   	*wv_name,
  ldh_tWBContext wv_wbctx,
  char		*volumename,
  int		(*bc_success)( void *, pwr_tVolumeId *, int),
  void		(*bc_cancel)(),
  int		(*bc_time_to_exit)( void *),
  int		show_volumes,
  wb_eType      wv_wb_type) : 
  WVsel(status,wv_parent_ctx,wv_name,wv_wbctx,volumename,bc_success,bc_cancel,
	bc_time_to_exit,show_volumes,wv_wb_type), parent_wid(wv_parent_wid)
{
  int		sts;
  pwr_tVolumeId volid, *volume_ptr;
  pwr_tVolumeId	volume;
  pwr_tClassId	classid;
  char		volname[80];
  int		size;
  int		volume_count;
  int		display_window;
  GtkCellRenderer *text_renderer;
  GtkTreeViewColumn *name_column;

  strcpy( volname, "");
  if ( volumename != NULL && *volumename != 0 && !show_volumes)
    /* Start the navigater for this volume */
    strcpy( volname, volumename);
  else if ( !show_volumes && wb_type != wb_eType_Buffer)
  {
    /* If there is only one volume in the db, select this volume */
    volume_count = 0;

    sts = ldh_GetVolumeList( wbctx, &volume);
    while ( ODD(sts) )
    {
      sts = ldh_GetVolumeClass( wbctx, volume, &classid);
      if (EVEN(sts)) { *status = sts; return; }
  
      if ( cdh_isClassVolumeClass( classid) ||
 	   classid == pwr_eClass_WorkBenchVolume ||
	   volume == ldh_cRtVolume)
      {
        sts = ldh_GetNextVolume( wbctx, volume, &volume);
        continue;
      }
      sts = ldh_VolumeIdToName( wbctx, volume, volname, sizeof(volname),
	    &size);
      if (EVEN(sts)) { *status = sts; return; }
      volume_count++;

      sts = ldh_GetNextVolume( wbctx, volume, &volume);
    }
    if ( volume_count != 1)
      strcpy( volname, "");
  }

  
  //  If volume name is supplied, find this volume and open the navigator.

  if ( strcmp( volname, "") && wb_type != wb_eType_Buffer)
    /* Check syntax, if new volumes is found, show the window */
    sts = check_volumelist( 1, &display_window);

  if ( strcmp( volname, "") && !display_window)
  {
    sts = ldh_VolumeNameToId( wbctx, volname, &volid);
    WFoe::error_msg(sts);
    if ( ODD(sts))
    {
      volume_ptr = (pwr_tVolumeId *) calloc( 1, sizeof( pwr_tVolumeId));
      *volume_ptr = volid;
      (vsel_bc_success) ( (void *)this, volume_ptr, 1);
      if (vsel_bc_cancel != NULL)
        (vsel_bc_cancel) ();

      *status = LOGIN__SUCCESS;
      return;
    }
    else
      printf( "-- Unable to open volume '%s', volume doesn't exist\n",
	volname);
  }


  // Create the window
  widgets.toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", 400,
					 "default-width", 500,
					 "title", name,
					 NULL);

  CoWowGtk::SetWindowIcon( widgets.toplevel);

  // Menu
  GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
  gtk_window_add_accel_group(GTK_WINDOW(widgets.toplevel), accel_g);

  GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);

  // File Entry
  GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
  g_signal_connect(file_close, "activate", G_CALLBACK(WVselGtk::activate_close), this);

  GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);

  GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));

  // Functions Entry
  GtkWidget *functions_showall = gtk_check_menu_item_new_with_mnemonic( "_Show All Volumes");
  g_signal_connect( functions_showall, "activate", 
		    G_CALLBACK(WVselGtk::activate_showall), this);
  gtk_widget_add_accelerator( functions_showall, "activate", accel_g,
			      'a', GdkModifierType(GDK_CONTROL_MASK), 
			      GTK_ACCEL_VISIBLE);

  GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
  gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_showall);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic("F_unctions");
  gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(functions_menu));

  // List widget
  store = gtk_list_store_new( 1, G_TYPE_STRING);

  widgets.volumelist = (GtkWidget *) g_object_new(GTK_TYPE_TREE_VIEW,
				 "model", store,
				 "rules-hint", TRUE,
				 "headers-visible", FALSE,
				 "reorderable", TRUE,
				 "enable-search", TRUE,
				 "search-column", 0,
				 NULL);

  text_renderer = gtk_cell_renderer_text_new();
  name_column = gtk_tree_view_column_new_with_attributes( NULL,
							  text_renderer,
							  "text", 0,
							  NULL);

  g_object_set( name_column,
		"resizable", TRUE,
		"clickable", TRUE,
		NULL);

  gtk_tree_view_append_column( GTK_TREE_VIEW(widgets.volumelist), name_column);

  GtkWidget *ok_button = gtk_button_new_with_label( "Ok");
  gtk_widget_set_size_request( ok_button, 70, 25);
  g_signal_connect( ok_button, "clicked", 
 		    G_CALLBACK(activate_ok), this);

  GtkWidget *cancel_button = gtk_button_new_with_label( "Cancel");
  gtk_widget_set_size_request( cancel_button, 70, 25);
  g_signal_connect( cancel_button, "clicked", 
 		    G_CALLBACK(activate_cancel), this);

  GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
  gtk_box_pack_start( GTK_BOX(hboxbuttons), ok_button, FALSE, FALSE, 20);
  gtk_box_pack_end( GTK_BOX(hboxbuttons), cancel_button, FALSE, FALSE, 20);

  GtkWidget *scrolled_window = gtk_scrolled_window_new( NULL, NULL);
  gtk_container_add( GTK_CONTAINER( scrolled_window), widgets.volumelist);

  GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
  gtk_box_pack_start( GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
  gtk_box_pack_end( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 10);

  gtk_container_add( GTK_CONTAINER(widgets.toplevel), vbox);
  gtk_widget_show_all( widgets.toplevel);

  // GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(widgets.volumelist));
  // gtk_tree_selection_set_mode( selection, GTK_SELECTION_SINGLE);

  sts = load_volumelist();
  WFoe::error_msg(sts);

  // Set input focus to the scrolled list widget
  gtk_widget_grab_focus( widgets.volumelist);


  wow = new CoWowGtk( widgets.toplevel);

  if ( wb_type != wb_eType_Buffer)
    sts = check_volumelist( 0, &display_window);

  *status = LOGIN__SUCCESS;
}