Exemple #1
0
MetaWindowMenu*
meta_window_menu_new   (MetaFrames         *frames,
                        MetaMenuOp          ops,
                        MetaMenuOp          insensitive,
                        Window              client_xwindow,
                        unsigned long       active_workspace,
                        int                 n_workspaces,
                        MetaWindowMenuFunc  func,
                        gpointer            data)
{
  int i;
  MetaWindowMenu *menu;

  /* FIXME: Modifications to 'ops' should happen in meta_window_show_menu */
  if (n_workspaces < 2)
    ops &= ~(META_MENU_OP_STICK | META_MENU_OP_UNSTICK | META_MENU_OP_WORKSPACES);
  else if (n_workspaces == 2)
    /* #151183: If we only have two workspaces, disable the menu listing them. */
    ops &= ~(META_MENU_OP_WORKSPACES);

  menu = g_new (MetaWindowMenu, 1);
  menu->frames = frames;
  menu->client_xwindow = client_xwindow;
  menu->func = func;
  menu->data = data;
  menu->ops = ops;
  menu->insensitive = insensitive;

  menu->menu = gtk_menu_new ();

  gtk_menu_set_screen (GTK_MENU (menu->menu),
                       gtk_widget_get_screen (GTK_WIDGET (frames)));

  for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++)
    {
      MenuItem menuitem = menuitems[i];
      if (ops & menuitem.op || menuitem.op == 0)
        {
          GtkWidget *mi;
          MenuData *md;
          unsigned int key;
          MetaVirtualModifier mods;

          mi = menu_item_new (&menuitem, -1);

          /* Set the activeness of radiobuttons. */
          if (menuitem.op == META_MENU_OP_STICK)
            {
              gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
                                              active_workspace == 0xFFFFFFFF);
            }
          else if (menuitem.op == META_MENU_OP_UNSTICK)
            {
              gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
                                              active_workspace != 0xFFFFFFFF);
            }

          if (menuitem.type == MENU_ITEM_WORKSPACE_LIST)
            {
              if (ops & META_MENU_OP_WORKSPACES)
                {
                  Display *display;
                  Window xroot;
                  GdkScreen *screen;
                  GdkWindow *window;
                  GtkWidget *submenu;
                  int j;

                  MenuItem to_another_workspace = {
                    0, MENU_ITEM_NORMAL, FALSE,
                    N_("Move to Another _Workspace")
                  };

                  meta_verbose ("Creating %d-workspace menu current space %lu\n",
                      n_workspaces, active_workspace);

                  window = gtk_widget_get_window (GTK_WIDGET (frames));
                  display = GDK_WINDOW_XDISPLAY (window);

                  screen = gdk_window_get_screen (window);
                  xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));

                  submenu = gtk_menu_new ();

                  g_assert (mi==NULL);
                  mi = menu_item_new (&to_another_workspace, -1);
                  gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), submenu);

                  for (j = 0; j < n_workspaces; j++)
                    {
                      char *label;
                      MenuItem moveitem;
                      GtkWidget *submi;

                      meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
                          j + 1,
                          &key, &mods);

                      label = get_workspace_name_with_accel (display, xroot, j);

                      moveitem.type = MENU_ITEM_NORMAL;
                      moveitem.op = META_MENU_OP_WORKSPACES;
                      moveitem.label = label;
                      submi = menu_item_new (&moveitem, j + 1);

                      g_free (label);

                      if ((active_workspace == (unsigned)j) && (ops & META_MENU_OP_UNSTICK))
                        gtk_widget_set_sensitive (submi, FALSE);

                      md = g_new (MenuData, 1);

                      md->menu = menu;
                      md->op = META_MENU_OP_WORKSPACES;

                      g_object_set_data (G_OBJECT (submi),
                          "workspace",
                          GINT_TO_POINTER (j));

                      g_signal_connect_data (G_OBJECT (submi),
                          "activate",
                          G_CALLBACK (activate_cb),
                          md,
                          (GClosureNotify) g_free, 0);

                      gtk_menu_shell_append (GTK_MENU_SHELL (submenu), submi);

                      gtk_widget_show (submi);
                    }
                  }
                else
                  meta_verbose ("not creating workspace menu\n");
            }
          else if (menuitem.type != MENU_ITEM_SEPARATOR)
            {
              meta_core_get_menu_accelerator (menuitems[i].op, -1,
                                              &key, &mods);

              if (insensitive & menuitem.op)
                gtk_widget_set_sensitive (mi, FALSE);

              md = g_new (MenuData, 1);

              md->menu = menu;
              md->op = menuitem.op;

              g_signal_connect_data (G_OBJECT (mi),
                                     "activate",
                                     G_CALLBACK (activate_cb),
                                     md,
                                     (GClosureNotify) g_free, 0);
            }

          if (mi)
            {
              gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi);

              gtk_widget_show (mi);
            }
        }
    }


  g_signal_connect (menu->menu, "selection_done",
                    G_CALLBACK (menu_closed), menu);

  return menu;
}
Exemple #2
0
static void
gui_restore_after_callback (Gimp               *gimp,
                            GimpInitStatusFunc  status_callback)
{
  GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (gimp->config);
  GimpDisplay   *display;

  if (gimp->be_verbose)
    g_print ("INIT: %s\n", G_STRFUNC);

  gimp->message_handler = GIMP_MESSAGE_BOX;

  /*  load the recent documents after gimp_real_restore() because we
   *  need the mime-types implemented by plug-ins
   */
  status_callback (NULL, _("Documents"), 0.9);
  gimp_recent_list_load (gimp);

  /*  enable this to always have icons everywhere  */
  if (g_getenv ("GIMP_ICONS_LIKE_A_BOSS"))
    {
      GdkScreen *screen = gdk_screen_get_default ();

      g_object_set (G_OBJECT (gtk_settings_get_for_screen (screen)),
                    "gtk-button-images", TRUE,
                    "gtk-menu-images",   TRUE,
                    NULL);
    }

  if (gui_config->restore_accels)
    menus_restore (gimp);

  ui_configurer = g_object_new (GIMP_TYPE_UI_CONFIGURER,
                                "gimp", gimp,
                                NULL);

  image_ui_manager = gimp_menu_factory_manager_new (global_menu_factory,
                                                    "<Image>",
                                                    gimp,
                                                    gui_config->tearoff_menus);
  gimp_ui_manager_update (image_ui_manager, gimp);

  gimp_action_history_init (gimp);

#ifdef GDK_WINDOWING_QUARTZ
  {
    GtkosxApplication *osx_app;
    GtkWidget         *menu;
    GtkWidget         *item;

    osx_app = gtkosx_application_get ();

    menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar");
    if (GTK_IS_MENU_ITEM (menu))
      menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));

    gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu));
    gtkosx_application_set_use_quartz_accelerators (osx_app, FALSE);

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         "/image-menubar/Help/dialogs-about", 0);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         "/image-menubar/Help/dialogs-search-action", 1);

#define PREFERENCES "/image-menubar/Edit/Preferences/"

    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-preferences", 3);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-input-devices", 4);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-keyboard-shortcuts", 5);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "dialogs-module-dialog", 6);
    gui_add_to_app_menu (image_ui_manager, osx_app,
                         PREFERENCES "plug-in-unit-editor", 7);

#undef PREFERENCES

    item = gtk_separator_menu_item_new ();
    gtkosx_application_insert_app_menu_item (osx_app, item, 8);

    item = gtk_ui_manager_get_widget (GTK_UI_MANAGER (image_ui_manager),
                                      "/image-menubar/File/file-quit");
    gtk_widget_hide (item);

    g_signal_connect (osx_app, "NSApplicationBlockTermination",
                      G_CALLBACK (gui_quartz_quit_callback),
                      image_ui_manager);

    gtkosx_application_ready (osx_app);
  }
#endif /* GDK_WINDOWING_QUARTZ */

  g_signal_connect_object (gui_config, "notify::single-window-mode",
                           G_CALLBACK (gui_single_window_mode_notify),
                           ui_configurer, 0);
  g_signal_connect_object (gui_config, "notify::tearoff-menus",
                           G_CALLBACK (gui_tearoff_menus_notify),
                           image_ui_manager, 0);
  g_signal_connect (image_ui_manager, "show-tooltip",
                    G_CALLBACK (gui_menu_show_tooltip),
                    gimp);
  g_signal_connect (image_ui_manager, "hide-tooltip",
                    G_CALLBACK (gui_menu_hide_tooltip),
                    gimp);

  gimp_devices_restore (gimp);
  gimp_controllers_restore (gimp, image_ui_manager);

  if (status_callback == splash_update)
    splash_destroy ();

  color_history_restore (gimp);

  if (gimp_get_show_gui (gimp))
    {
      GimpDisplayShell *shell;
      GtkWidget        *toplevel;

      /*  create the empty display  */
      display = GIMP_DISPLAY (gimp_create_display (gimp, NULL,
                                                   GIMP_UNIT_PIXEL, 1.0,
                                                   G_OBJECT (initial_screen),
                                                   initial_monitor));

      shell = gimp_display_get_shell (display);

      if (gui_config->restore_session)
        session_restore (gimp,
                         initial_screen,
                         initial_monitor);

      /*  move keyboard focus to the display  */
      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
      gtk_window_present (GTK_WINDOW (toplevel));
    }

  /*  indicate that the application has finished loading  */
  gdk_notify_startup_complete ();

  /*  clear startup monitor variables  */
  initial_screen  = NULL;
  initial_monitor = -1;
}
Exemple #3
0
static void notify_incoming_call(struct gtk_mod *mod,
		struct call *call)
{
	static const char *title = "Incoming call";
	const char *msg = call_peeruri(call);
	GtkWidget *call_menu;
	GtkWidget *menu_item;
#if defined(USE_LIBNOTIFY)
	NotifyNotification *notification;

	if (!notify_is_initted())
		return;
	notification = notify_notification_new(title, msg, "baresip");
	notify_notification_set_urgency(notification, NOTIFY_URGENCY_CRITICAL);
	notify_notification_show(notification, NULL);
	g_object_unref(notification);

#elif GLIB_CHECK_VERSION(2,40,0)
	char id[64];
	GVariant *target;
	GNotification *notification = g_notification_new(title);

	re_snprintf(id, sizeof id, "incoming-call-%p", call);
	id[sizeof id - 1] = '\0';

#if GLIB_CHECK_VERSION(2,42,0)
	g_notification_set_priority(notification,
			G_NOTIFICATION_PRIORITY_URGENT);
#else
	g_notification_set_urgent(notification, TRUE);
#endif

	target = g_variant_new_int64(GPOINTER_TO_INT(call));
	g_notification_set_body(notification, msg);
	g_notification_add_button_with_target_value(notification,
			"Answer", "app.answer", target);
	g_notification_add_button_with_target_value(notification,
			"Reject", "app.reject", target);
	g_application_send_notification(mod->app, id, notification);
	g_object_unref(notification);

#else
	(void)msg;
	(void)title;
#endif

	/* Add incoming call to the app menu */
	call_menu = gtk_menu_new();
	menu_item = gtk_menu_item_new_with_mnemonic("_Incoming call");
	g_object_set_data(G_OBJECT(menu_item), "call", call);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
			call_menu);
	gtk_menu_shell_prepend(GTK_MENU_SHELL(mod->app_menu), menu_item);
	mod->incoming_call_menus = g_slist_append(mod->incoming_call_menus,
			menu_item);

	menu_item = gtk_menu_item_new_with_label(call_peeruri(call));
	gtk_widget_set_sensitive(menu_item, FALSE);
	gtk_menu_shell_append(GTK_MENU_SHELL(call_menu), menu_item);

	menu_item = gtk_menu_item_new_with_mnemonic("_Accept");
	g_object_set_data(G_OBJECT(menu_item), "call", call);
	g_signal_connect(G_OBJECT(menu_item), "activate",
			G_CALLBACK(menu_on_incoming_call_answer), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(call_menu), menu_item);

	menu_item = gtk_menu_item_new_with_mnemonic("_Reject");
	g_object_set_data(G_OBJECT(menu_item), "call", call);
	g_signal_connect(G_OBJECT(menu_item), "activate",
			G_CALLBACK(menu_on_incoming_call_reject), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(call_menu), menu_item);
}
Exemple #4
0
GtkUIManager *
gl_ui_new (glWindow *window)
{
	GtkUIManager            *ui;
	GtkActionGroup          *actions;
	GError                  *error = NULL;
	GtkWidget               *recent_menu;

	gl_debug (DEBUG_UI, "START");

	g_return_val_if_fail (window && GL_IS_WINDOW (window), NULL);

	gl_debug (DEBUG_UI, "window = %p", window);

	ui = gtk_ui_manager_new ();

	g_signal_connect (ui, "connect_proxy",
			  G_CALLBACK (connect_proxy_cb), window);
	g_signal_connect (ui, "disconnect_proxy",
			  G_CALLBACK (disconnect_proxy_cb), window);

	actions = gtk_action_group_new ("Actions");
        gtk_action_group_set_translation_domain (actions, NULL);
	gtk_action_group_add_actions (actions, entries, n_entries, GTK_WINDOW (window));
	gtk_action_group_add_toggle_actions (actions, 
					     toggle_entries, n_toggle_entries, 
					     window);
	gtk_action_group_add_toggle_actions (actions, 
					     ui_toggle_entries, n_ui_toggle_entries, 
					     ui);

	gtk_ui_manager_insert_action_group (ui, actions, 0);
	gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui));

	gl_debug (DEBUG_UI, "Creating ui from string");
	if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, strlen (ui_info), &error)) {
		g_message ("building menus failed: %s", error->message);
		g_error_free (error);
	}

	/* Set the toolbar styles according to prefs */
	set_app_main_toolbar_style (ui);
	set_app_drawing_toolbar_style (ui);
		
	/* Set view grid and markup visibility according to prefs */
	set_view_style (ui);
		
	/* add an Open Recents Submenu */
        recent_menu  = gl_recent_create_menu ();
	g_signal_connect (G_OBJECT (recent_menu), "item-activated",
			  G_CALLBACK (gl_ui_cmd_file_open_recent), window);
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (gtk_ui_manager_get_widget (ui, "/MenuBar/FileMenu/FileRecentsMenu")),
				   recent_menu);


        set_additional_properties (ui);

	gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE);
	gl_ui_util_set_verb_list_sensitive (ui, paste_verbs, FALSE);

	gl_debug (DEBUG_UI, "END");

	return ui;
}
int main(int argc, char *argv[] ) {
    
	int i;
	char track_text[4];


        gtk_init (&argc, &argv);


        
        id3win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(id3win),"MP3info - An ID3 tag editor");
        gtk_window_set_policy (GTK_WINDOW(id3win), FALSE,FALSE,FALSE);
        gtk_widget_set_usize(id3win,450,360);
        gtk_container_border_width(GTK_CONTAINER(id3win),5);
        gtk_signal_connect(GTK_OBJECT(id3win), "delete_event", (GtkSignalFunc) gtk_exit, NULL);
        id3win_frame_global=gtk_vbox_new(FALSE,5);

	/* rmcc was here */

	id3win_menu_bar = gtk_menu_bar_new();
	gtk_widget_show(id3win_menu_bar);
	gtk_box_pack_start(GTK_BOX(id3win_frame_global), id3win_menu_bar, FALSE, TRUE, 1);

	id3win_menu_file = gtk_menu_item_new_with_label("File");
	gtk_widget_show(id3win_menu_file);
	gtk_container_add(GTK_CONTAINER(id3win_menu_bar), id3win_menu_file);
	id3win_menu_fcont = gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(id3win_menu_file), id3win_menu_fcont);

	id3win_menu_open = gtk_menu_item_new_with_label("Open New    ");
	gtk_widget_show(id3win_menu_open);
	gtk_container_add(GTK_CONTAINER(id3win_menu_fcont), id3win_menu_open);
	gtk_signal_connect(GTK_OBJECT(id3win_menu_open), "activate",
	                   GTK_SIGNAL_FUNC(open_mp3_file),
	                   NULL);

	id3win_menu_info = gtk_menu_item_new_with_label("Info        ");
	gtk_widget_show(id3win_menu_info);
	gtk_container_add(GTK_CONTAINER(id3win_menu_fcont), id3win_menu_info);
	gtk_signal_connect(GTK_OBJECT(id3win_menu_info), "activate",
	                   GTK_SIGNAL_FUNC(create_techinfo_win),
	                   NULL);

	id3win_menu_help = gtk_menu_item_new_with_label("      Help");
	gtk_widget_show(id3win_menu_help);
	gtk_container_add(GTK_CONTAINER(id3win_menu_bar), id3win_menu_help);
	gtk_menu_item_right_justify(GTK_MENU_ITEM(id3win_menu_help));
	id3win_menu_hcont = gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(id3win_menu_help), id3win_menu_hcont);

	id3win_menu_about = gtk_menu_item_new_with_label("About    ");
	gtk_widget_show(id3win_menu_about);
	gtk_container_add(GTK_CONTAINER(id3win_menu_hcont), id3win_menu_about);
	gtk_signal_connect(GTK_OBJECT(id3win_menu_about), "activate",
	                   GTK_SIGNAL_FUNC(about_mp3info),
	                   NULL);


	/* rmcc has left the building */
        
        id3win_frame_title=gtk_frame_new("Title");
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_title),5);
        id3win_text_title=gtk_entry_new_with_max_length(30);
        gtk_container_add(GTK_CONTAINER(id3win_frame_title),id3win_text_title);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_title,TRUE,TRUE,0);
        
        id3win_frame_artist=gtk_frame_new("Artist");
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_artist),5);
        id3win_text_artist=gtk_entry_new_with_max_length(30);
        gtk_container_add(GTK_CONTAINER(id3win_frame_artist),id3win_text_artist);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_artist,TRUE,TRUE,0);
        
        id3win_frame_albyear=gtk_hbox_new(FALSE,30);
        id3win_frame_album=gtk_frame_new("Album");
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_album),5);
        id3win_text_album=gtk_entry_new_with_max_length(30);
        gtk_container_add(GTK_CONTAINER(id3win_frame_album),id3win_text_album);
        gtk_box_pack_start(GTK_BOX(id3win_frame_albyear),id3win_frame_album,TRUE,TRUE,0);
        
        id3win_frame_year=gtk_frame_new("Year");
        gtk_widget_set_usize(id3win_frame_year,2,0);
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_year),5);
        id3win_text_year=gtk_entry_new_with_max_length(4);
        gtk_container_add(GTK_CONTAINER(id3win_frame_year),id3win_text_year);
        gtk_box_pack_start(GTK_BOX(id3win_frame_albyear),id3win_frame_year,TRUE,TRUE,0);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_albyear,TRUE,TRUE,0);
        
        id3win_frame_comtrack=gtk_hbox_new(FALSE,30);
        id3win_frame_comment=gtk_frame_new("Comment");
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_comment),5);
        id3win_text_comment=gtk_entry_new_with_max_length(30);
        gtk_container_add(GTK_CONTAINER(id3win_frame_comment),id3win_text_comment);
        gtk_box_pack_start(GTK_BOX(id3win_frame_comtrack),id3win_frame_comment,TRUE,TRUE,0);
        
        id3win_frame_track=gtk_frame_new("Track");
        gtk_widget_set_usize(id3win_frame_track,2,0);
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_track),5);
        id3win_text_track=gtk_entry_new_with_max_length(3);
        gtk_container_add(GTK_CONTAINER(id3win_frame_track),id3win_text_track);
        gtk_box_pack_start(GTK_BOX(id3win_frame_comtrack),id3win_frame_track,TRUE,TRUE,0);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_comtrack,TRUE,TRUE,0);
        
        id3win_frame_genre=gtk_frame_new("Genre");
        gtk_container_border_width(GTK_CONTAINER(id3win_frame_genre),5);
        id3win_combo_genre=gtk_combo_new();
        for(i=0;i<MAXGENRE+2;i++) {
        	genrelist = g_list_append(genrelist, typegenre[galphagenreindex[i]]);
        }
        gtk_combo_set_popdown_strings(GTK_COMBO(id3win_combo_genre),genrelist);
        gtk_container_add(GTK_CONTAINER(id3win_frame_genre),id3win_combo_genre);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_genre,TRUE,TRUE,0);
        
        id3win_frame_buttons=gtk_hbox_new(TRUE,30);
        id3win_ok_button=gtk_button_new_with_label("OK");
        gtk_box_pack_start(GTK_BOX(id3win_frame_buttons),id3win_ok_button,TRUE,TRUE,0);
	if(read_only) {
	  gtk_widget_set_sensitive (id3win_text_title, FALSE);
	  gtk_widget_set_sensitive (id3win_text_artist, FALSE);
	  gtk_widget_set_sensitive (id3win_text_album, FALSE);
	  gtk_widget_set_sensitive (id3win_text_year, FALSE);
	  gtk_widget_set_sensitive (id3win_text_comment, FALSE);
	  gtk_widget_set_sensitive (id3win_text_track, FALSE);
	  gtk_widget_set_sensitive (id3win_combo_genre, FALSE);	
	} else {
	        id3win_cancel_button=gtk_button_new_with_label("Cancel");
        	gtk_box_pack_start(GTK_BOX(id3win_frame_buttons),id3win_cancel_button,TRUE,TRUE,0);
	        gtk_signal_connect (GTK_OBJECT (id3win_cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_exit), NULL);
        }

        gtk_widget_set_usize(id3win_frame_buttons,30,20);
        gtk_box_pack_start(GTK_BOX(id3win_frame_global),id3win_frame_buttons,TRUE,TRUE,0);
        
        gtk_container_add(GTK_CONTAINER(id3win),id3win_frame_global);
        
        gtk_signal_connect (GTK_OBJECT (id3win_ok_button), "clicked", GTK_SIGNAL_FUNC (exit_save), NULL);
        
        gtk_widget_show_all(id3win);
        
	memset(&mp3,0,sizeof(mp3info));

	if(argc==2) { 
	   if (! load_mp3(argv[1])) {
		exit(0);
	   }
           gtk_entry_set_text(GTK_ENTRY(id3win_text_title),mp3.id3.title);
           gtk_entry_set_text(GTK_ENTRY(id3win_text_artist),mp3.id3.artist);
           gtk_entry_set_text(GTK_ENTRY(id3win_text_album),mp3.id3.album);
           gtk_entry_set_text(GTK_ENTRY(id3win_text_year),mp3.id3.year);
           gtk_entry_set_text(GTK_ENTRY(id3win_text_comment),mp3.id3.comment);
	   if(mp3.id3.track[0] > 0)
		sprintf(track_text,"%d",(int)mp3.id3.track[0]);
	   else
		track_text[0]=0;
	   gtk_entry_set_text(GTK_ENTRY(id3win_text_track),track_text);
           gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(id3win_combo_genre)->entry), gtext_genre(mp3.id3.genre[0]));
    
	} else {
	   open_mp3_file();
	}

        gtk_main();
	return(0);
			
}
int main (int argc, char *argv[])
{
    /* Vars */
    GtkWidget *vbox;
    GtkWidget *window;
    GtkWidget *table;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *button;
    GtkWidget* scrolled;
    GtkWidget *menubar;
    GtkWidget *filemenu;
    GtkWidget *file;
    GtkWidget *quit;
    GtkWidget *reindexer;
    
    /* Set default directory to index */
    indexdir = ".";
    
    /* Run the indexer */
    reindex(NULL, NULL);
    
    /* Create the search objects */
    createSearch();

    /* Make the GUI */
    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    initialize_window(window);

    /* Create a 10x5 table */
    table = gtk_table_new (10, 5, FALSE);
    gtk_container_add (GTK_CONTAINER (window), table);

    /* create a new label. */
    label = gtk_label_new ("Search Terms:" );

    gtk_table_set_homogeneous(GTK_TABLE (table), TRUE);
    gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);

    entry = gtk_entry_new ();
    gtk_entry_set_max_length (GTK_ENTRY (entry),1000);
    gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 3, 1, 2);
    
    button = gtk_button_new_with_label ("OR Search");
    gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (orsearch), (gpointer) entry);
    gtk_table_attach_defaults (GTK_TABLE (table), button, 3, 4, 1, 2);
    
    button = gtk_button_new_with_label ("AND Search");
    gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (andsearch), (gpointer) entry);
    gtk_table_attach_defaults (GTK_TABLE (table), button, 4, 5, 1, 2);
    
    textview  = gtk_text_view_new();
    gtk_text_view_set_editable( GTK_TEXT_VIEW (textview), 0);
    gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), 0);
    scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add (GTK_CONTAINER (scrolled), textview);
    gtk_table_attach_defaults (GTK_TABLE (table), scrolled, 0, 5, 2, 10);


    vbox = gtk_vbox_new(FALSE, 0);
    gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 5, 0, 1);

    menubar = gtk_menu_bar_new();
    filemenu = gtk_menu_new();

    file = gtk_menu_item_new_with_label("File");
    reindexer = gtk_menu_item_new_with_label("Reindex");
    gtk_signal_connect (GTK_OBJECT (reindexer), "activate", G_CALLBACK(reindex), NULL);
    quit = gtk_menu_item_new_with_label("Quit");
    gtk_signal_connect (GTK_OBJECT (quit), "activate", G_CALLBACK(destroy), NULL);

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), reindexer);
    gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
    gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
    gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);


    gtk_widget_show_all(window);

    gtk_main ();
    return 0;
}
Exemple #7
0
static void
create_colors (void)
{
   static GtkWidget *window = NULL;
   GtkWidget *box1 = NULL;
   GtkWidget *box2 = NULL;
   GtkWidget *close_button = NULL;
   GtkWidget *box = NULL;
   GtkWidget *separator;
   GtkWidget *label;
   GtkWidget *menu;
   GtkWidget *root_menu;
   GtkWidget *menu_bar;
   gfloat *X = NULL;
   gfloat *Y = NULL;
   gint i, j;
   GdkColor color;
   GtkDataboxGraph *graph;

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_widget_set_size_request (window, 500, 300);

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

   gtk_window_set_title (GTK_WINDOW (window), "GtkDatabox: Colors");
   gtk_container_set_border_width (GTK_CONTAINER (window), 0);

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

   box = gtk_databox_new ();
   gtk_databox_set_enable_selection (GTK_DATABOX (box), FALSE);
   gtk_databox_set_enable_zoom (GTK_DATABOX (box), FALSE);

   color.red = 0;
   color.green = 0;
   color.blue = 0;
   gtk_widget_modify_bg (box, GTK_STATE_NORMAL, &color);

   menu = gtk_menu_new ();
   root_menu = gtk_menu_item_new_with_label ("Color Menu");
   gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);
   menu_bar = gtk_menu_bar_new ();
   gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
   gtk_box_pack_start (GTK_BOX (box1), menu_bar, FALSE, TRUE, 0);


   label =
      gtk_label_new
      ("You can change the colors of the shown datasets via the menu.\n\n");
   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
   separator = gtk_hseparator_new ();
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, FALSE, 0);

   g_signal_connect (G_OBJECT (box), "destroy",
		     G_CALLBACK (gtk_main_quit), NULL);


   for (i = 0; i < NO_OF_DATASETS; i++)
   {
      if (!i)
	 X = g_new0 (gfloat, POINTS);
      Y = g_new0 (gfloat, POINTS);
      for (j = 0; j < POINTS; j++)
      {
	 X[j] = j;
	 Y[j] = 100. * sin ((i + 1) * 2 * j * G_PI / POINTS);
      }
      color.red = 65535 * ((i + 1) % 2);
      color.green = (65535 / 2) * ((i + 1) % 3);
      color.blue = (65535 / 3) * ((i + 1) % 4);
      graph = gtk_databox_points_new (POINTS, X, Y, &color, 1);
      gtk_databox_graph_add (GTK_DATABOX (box), graph);
      create_menu_entry (menu, i, box, graph);
   }

   gtk_databox_auto_rescale (GTK_DATABOX (box), 0.05);

   gtk_box_pack_start (GTK_BOX (box1), box, TRUE, TRUE, 0);

   separator = gtk_hseparator_new ();
   gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

   box2 = gtk_vbox_new (FALSE, 10);
   gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
   gtk_box_pack_end (GTK_BOX (box1), box2, FALSE, TRUE, 0);
   close_button = gtk_button_new_with_label ("close");
   g_signal_connect (G_OBJECT (close_button), "clicked",
		     G_CALLBACK (gtk_main_quit), (gpointer) NULL);
   gtk_box_pack_start (GTK_BOX (box2), close_button, TRUE, TRUE, 0);
   GTK_WIDGET_SET_FLAGS (close_button, GTK_CAN_DEFAULT);
   gtk_widget_grab_default (close_button);





   gtk_widget_show_all (window);

}
Exemple #8
0
static void *menu_get_mainwidget( void *data )
{
   GtkWidget *menu_item = (GtkWidget *) data;
   return gtk_menu_item_get_submenu( GTK_MENU_ITEM( menu_item) );
}
Exemple #9
0
GtkWidget *vf_pop_menu(ViewFile *vf)
{
	GtkWidget *menu;
	GtkWidget *item;
	GtkWidget *submenu;
	gboolean active = FALSE;

	switch (vf->type)
	{
	case FILEVIEW_LIST:
		vflist_color_set(vf, VFLIST(vf)->click_fd, TRUE);
		active = (VFLIST(vf)->click_fd != NULL);
		break;
	case FILEVIEW_ICON:
		active = (VFICON(vf)->click_id != NULL);
		break;
	}

	menu = popup_menu_short_lived();

	g_signal_connect(G_OBJECT(menu), "destroy",
			 G_CALLBACK(vf_popup_destroy_cb), vf);

	if (vf->clicked_mark > 0)
		{
		gint mark = vf->clicked_mark;
		gchar *str_set_mark = g_strdup_printf(_("_Set mark %d"), mark);
		gchar *str_res_mark = g_strdup_printf(_("_Reset mark %d"), mark);
		gchar *str_toggle_mark = g_strdup_printf(_("_Toggle mark %d"), mark);
		gchar *str_sel_mark = g_strdup_printf(_("_Select mark %d"), mark);
		gchar *str_sel_mark_or = g_strdup_printf(_("_Add mark %d"), mark);
		gchar *str_sel_mark_and = g_strdup_printf(_("_Intersection with mark %d"), mark);
		gchar *str_sel_mark_minus = g_strdup_printf(_("_Unselect mark %d"), mark);

		g_assert(mark >= 1 && mark <= FILEDATA_MARKS_SIZE);

		vf->active_mark = mark;
		vf->clicked_mark = 0;

		menu_item_add_sensitive(menu, str_set_mark, active,
					G_CALLBACK(vf_pop_menu_set_mark_sel_cb), vf);

		menu_item_add_sensitive(menu, str_res_mark, active,
					G_CALLBACK(vf_pop_menu_res_mark_sel_cb), vf);

		menu_item_add_sensitive(menu, str_toggle_mark, active,
					G_CALLBACK(vf_pop_menu_toggle_mark_sel_cb), vf);

		menu_item_add_divider(menu);

		menu_item_add_sensitive(menu, str_sel_mark, active,
					G_CALLBACK(vf_pop_menu_sel_mark_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_or, active,
					G_CALLBACK(vf_pop_menu_sel_mark_or_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_and, active,
					G_CALLBACK(vf_pop_menu_sel_mark_and_cb), vf);
		menu_item_add_sensitive(menu, str_sel_mark_minus, active,
					G_CALLBACK(vf_pop_menu_sel_mark_minus_cb), vf);

		menu_item_add_divider(menu);

		g_free(str_set_mark);
		g_free(str_res_mark);
		g_free(str_toggle_mark);
		g_free(str_sel_mark);
		g_free(str_sel_mark_and);
		g_free(str_sel_mark_or);
		g_free(str_sel_mark_minus);
		}

	vf->editmenu_fd_list = vf_pop_menu_file_list(vf);
	submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf, vf->editmenu_fd_list);
	gtk_widget_set_sensitive(item, active);

	menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active,
				      G_CALLBACK(vf_pop_menu_view_cb), vf);

	menu_item_add_divider(menu);
	menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active,
				      G_CALLBACK(vf_pop_menu_copy_cb), vf);
	menu_item_add_sensitive(menu, _("_Move..."), active,
				G_CALLBACK(vf_pop_menu_move_cb), vf);
	menu_item_add_sensitive(menu, _("_Rename..."), active,
				G_CALLBACK(vf_pop_menu_rename_cb), vf);
	menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active,
				      G_CALLBACK(vf_pop_menu_delete_cb), vf);
	menu_item_add_sensitive(menu, _("_Copy path"), active,
				G_CALLBACK(vf_pop_menu_copy_path_cb), vf);

	menu_item_add_sensitive(menu, _("Enable file _grouping"), active,
				G_CALLBACK(vf_pop_menu_enable_grouping_cb), vf);
	menu_item_add_sensitive(menu, _("Disable file groupi_ng"), active,
				G_CALLBACK(vf_pop_menu_disable_grouping_cb), vf);

	menu_item_add_divider(menu);

	submenu = submenu_add_sort(NULL, G_CALLBACK(vf_pop_menu_sort_cb), vf,
				   FALSE, FALSE, TRUE, vf->sort_method);
	menu_item_add_divider(submenu);
	menu_item_add_check(submenu, _("Ascending"), vf->sort_ascend,
			    G_CALLBACK(vf_pop_menu_sort_ascend_cb), vf);

	item = menu_item_add(menu, _("_Sort"), NULL, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);

	item = menu_item_add_radio(menu, _("View as _List"), GINT_TO_POINTER(FILEVIEW_LIST), vf->type == FILEVIEW_LIST,
                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);

	item = menu_item_add_radio(menu, _("View as _Icons"), GINT_TO_POINTER(FILEVIEW_ICON), vf->type == FILEVIEW_ICON,
                                           G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf);

	switch (vf->type)
	{
	case FILEVIEW_LIST:
		menu_item_add_check(menu, _("Show _thumbnails"), VFLIST(vf)->thumbs_enabled,
				    G_CALLBACK(vflist_pop_menu_thumbs_cb), vf);
		break;
	case FILEVIEW_ICON:
		menu_item_add_check(menu, _("Show filename _text"), VFICON(vf)->show_text,
				    G_CALLBACK(vficon_pop_menu_show_names_cb), vf);
		break;
	}
	
	menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vf_pop_menu_refresh_cb), vf);

	return menu;
}
Exemple #10
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));

  }  
}
Exemple #11
0
/*
	creates the right click menu for open gl canvas
	params:gtk widget to assign menu
	return value:gtkmenu itself
*/
GtkWidget *create_popup_menu(GtkWidget * drawing_area)
{
    GtkWidget *actions_menu;
    GtkWidget *editing_menu;
    GtkWidget *menu;
    GtkWidget *menu_item;
    int mm = 0;
    /*actions sub menu */
    //PAN   

    mm = MM_PAN;
    actions_menu = gtk_menu_new();
    menu_item = gtk_menu_item_new_with_label("Pan");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    //ZOOM
    mm = MM_ZOOM;
    menu_item = gtk_menu_item_new_with_label("Zoom");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    //ROTATE
    mm = MM_ROTATE;
    menu_item = gtk_menu_item_new_with_label("rotate");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
/**********/
    //Single Select
    mm = MM_SINGLE_SELECT;
    menu_item = gtk_menu_item_new_with_label("select");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    //Rectangle Select
    mm = MM_RECTANGULAR_SELECT;
    menu_item = gtk_menu_item_new_with_label("rect select");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
/**********/
    //Rectangle -x Select
    mm = MM_RECTANGULAR_X_SELECT;
    menu_item = gtk_menu_item_new_with_label("rect-x select");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
/**********/
    //Move
    mm = MM_MOVE;
    menu_item = gtk_menu_item_new_with_label("Move");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    //activate magnifier
    mm = MM_MAGNIFIER;		//magnifier ,fisheye etc starts at 20
    menu_item = gtk_menu_item_new_with_label("Magnifier");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    //activate fisheye magnifier
    mm = MM_FISHEYE_MAGNIFIER;
    menu_item = gtk_menu_item_new_with_label("Fisheye Magnifier");
    gtk_menu_shell_append(GTK_MENU_SHELL(actions_menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(switch_Mouse), (gpointer) mm);
    gtk_widget_show(menu_item);
/**********/
    editing_menu = gtk_menu_new();
    /* NODE */
    menu_item = gtk_menu_item_new_with_label("Node");
    gtk_menu_shell_append(GTK_MENU_SHELL(editing_menu), menu_item);
    gtk_widget_show(menu_item);

    /* EDGE */
    menu_item = gtk_menu_item_new_with_label("Edge");
    gtk_menu_shell_append(GTK_MENU_SHELL(editing_menu), menu_item);
    gtk_widget_show(menu_item);


    menu = gtk_menu_new();

    /* Actions */
    menu_item = gtk_menu_item_new_with_label("Mouse");
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), actions_menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
    gtk_widget_show(menu_item);

    /* NEW */
    menu_item = gtk_menu_item_new_with_label("New");
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), editing_menu);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
    gtk_widget_show(menu_item);

    /* Quit */
    menu_item = gtk_menu_item_new_with_label("Quit");
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
    g_signal_connect(G_OBJECT(menu_item), "activate",
		     G_CALLBACK(gtk_main_quit), NULL);
    gtk_widget_show(menu_item);
    return menu;
}
Exemple #12
0
/* Constructs the main program window. The specified mode will be the one
 * initially selected in the Vis menu */
void
window_init( FsvMode fsv_mode )
{
	GtkWidget *main_window_w;
	GtkWidget *main_vbox_w;
	GtkWidget *menu_bar_w;
	GtkWidget *menu_w;
	GtkWidget *menu_item_w;
	GtkWidget *hpaned_w;
	GtkWidget *vpaned_w;
	GtkWidget *left_vbox_w;
	GtkWidget *right_vbox_w;
	GtkWidget *hbox_w;
	GtkWidget *button_w;
	GtkWidget *frame_w;
	GtkWidget *dir_ctree_w;
	GtkWidget *file_clist_w;
        GtkWidget *gl_area_w;
	GtkWidget *x_scrollbar_w;
	GtkWidget *y_scrollbar_w;
	int window_width, window_height;

	/* Main window widget */
	main_window_w = gtk_window_new( GTK_WINDOW_TOPLEVEL );
	gtk_window_set_title( GTK_WINDOW(main_window_w), "fsv" );
	gtk_window_set_wmclass( GTK_WINDOW(main_window_w), "main", "fsv" );
	gtk_window_set_policy( GTK_WINDOW(main_window_w), TRUE, TRUE, TRUE );
	window_width = 3 * gdk_screen_width( ) / 4;
	window_height = 2584 * window_width / 4181;
	gtk_widget_set_usize( main_window_w, window_width, window_height );
	gtk_signal_connect( GTK_OBJECT(main_window_w), "delete_event", GTK_SIGNAL_FUNC(gtk_main_quit), NULL );
	gtk_quit_add_destroy( 1, GTK_OBJECT(main_window_w) );

	/* Main vertical box widget */
	main_vbox_w = gui_vbox_add( main_window_w, 0 );

	/* Build menu bar */

	/* Menu bar widget */
	menu_bar_w = gtk_menu_bar_new( );
	gtk_box_pack_start( GTK_BOX(main_vbox_w), menu_bar_w, FALSE, FALSE, 0 );
	gtk_widget_show( menu_bar_w );

	/* File menu */
	menu_w = gui_menu_add( menu_bar_w, _("File") );
	/* File menu items */
	menu_item_w = gui_menu_item_add( menu_w, _("Change root..."), on_file_change_root_activate, NULL );
	gui_keybind( menu_item_w, _("^N") );
	G_LIST_APPEND(sw_widget_list, menu_item_w);
#if 0
	gui_menu_item_add( menu_w, _("Save settings"), on_file_save_settings_activate, NULL );
#endif
	gui_separator_add( menu_w );
	menu_item_w = gui_menu_item_add( menu_w, _("Exit"), on_file_exit_activate, NULL );
	gui_keybind( menu_item_w, _("^Q") );

	/* Vis menu */
	menu_w = gui_menu_add( menu_bar_w, _("Vis") );
	/* Vis menu items */
	gui_radio_menu_begin( fsv_mode -1 );
#if 0 /* DiscV mode needs more work */
	gui_radio_menu_item_add( menu_w, _("DiscV"), on_vis_discv_activate, NULL );
/* Note: don't forget to remove the "-1" three lines up */
#endif
	gui_radio_menu_item_add( menu_w, _("MapV"), on_vis_mapv_activate, NULL );
	gui_radio_menu_item_add( menu_w, _("TreeV"), on_vis_treev_activate, NULL );

	/* Color menu */
	menu_w = gui_menu_add( menu_bar_w, _("Colors") );
	/* Color menu items */
	gui_radio_menu_begin( 0 );
	menu_item_w = gui_radio_menu_item_add( menu_w, _("By node type"), on_color_by_nodetype_activate, NULL );
	G_LIST_APPEND(sw_widget_list, menu_item_w);
	color_by_nodetype_rmenu_item_w = menu_item_w;
	menu_item_w = gui_radio_menu_item_add( menu_w, _("By timestamp"), on_color_by_timestamp_activate, NULL );
	G_LIST_APPEND(sw_widget_list, menu_item_w);
	color_by_timestamp_rmenu_item_w = menu_item_w;
	menu_item_w = gui_radio_menu_item_add( menu_w, _("By wildcards"), on_color_by_wildcards_activate, NULL );
	G_LIST_APPEND(sw_widget_list, menu_item_w);
	color_by_wpattern_rmenu_item_w = menu_item_w;
	gui_separator_add( menu_w );
	gui_menu_item_add( menu_w, _("Setup..."), on_color_setup_activate, NULL );

#ifdef DEBUG
	/* Debug menu */
	menu_w = gui_menu_add( menu_bar_w, "Debug" );
	/* Debug menu items */
	gui_menu_item_add( menu_w, "Memory totals", debug_show_mem_totals, NULL );
	gui_menu_item_add( menu_w, "Memory summary", debug_show_mem_summary, NULL );
	gui_menu_item_add( menu_w, "Memory stats", debug_show_mem_stats, NULL );
	gui_separator_add( menu_w );
	gui_menu_item_add( menu_w, "GLib memory profile", g_mem_profile, NULL );
	gui_menu_item_add( menu_w, "GMemChunk info", g_mem_chunk_info, NULL );
#endif

	/* Help menu (right-justified) */
	menu_w = gui_menu_add( menu_bar_w, _("Help") );
	gtk_menu_item_right_justify( GTK_MENU_ITEM(GTK_MENU(menu_w)->parent_menu_item) );
	/* Help menu items */
	gui_menu_item_add( menu_w, _("Contents..."), on_help_contents_activate, NULL );
	gui_separator_add( menu_w );
	gui_menu_item_add( menu_w, _("About fsv..."), on_help_about_fsv_activate, NULL );

	/* Done with the menu bar */

	/* Main horizontal paned widget */
	hpaned_w = gui_hpaned_add( main_vbox_w, window_width / 5 );

	/* Vertical box for everything in the left pane */
	left_vbox_w = gtk_vbox_new( FALSE, 0 );
	gtk_paned_add1( GTK_PANED(hpaned_w), left_vbox_w );
	gtk_widget_show( left_vbox_w );

	/* Horizontal box for toolbar buttons */
	hbox_w = gui_hbox_add( left_vbox_w, 2 );

	/* "back" button */
	button_w = gui_button_add( hbox_w, NULL, on_back_button_clicked, NULL );
	gui_pixmap_xpm_add( button_w, back_xpm );
	G_LIST_APPEND(sw_widget_list, button_w);
	/* "cd /" button */
	button_w = gui_button_add( hbox_w, NULL, on_cd_root_button_clicked, NULL );
	gui_pixmap_xpm_add( button_w, cd_root_xpm );
	G_LIST_APPEND(sw_widget_list, button_w);
	/* "cd .." button */
	button_w = gui_button_add( hbox_w, NULL, on_cd_up_button_clicked, NULL );
	gui_pixmap_xpm_add( button_w, cd_up_xpm );
	G_LIST_APPEND(sw_widget_list, button_w);
	/* "bird's-eye view" toggle button */
	button_w = gui_toggle_button_add( hbox_w, NULL, FALSE, on_birdseye_view_togglebutton_toggled, NULL );
	gui_pixmap_xpm_add( button_w, birdseye_view_xpm );
	G_LIST_APPEND(sw_widget_list, button_w);
	birdseye_view_tbutton_w = button_w;

	/* Frame to encase the directory tree / file list */
	frame_w = gui_frame_add( left_vbox_w, NULL );

	/* Vertical paned widget for directory tree / file list */
	vpaned_w = gui_vpaned_add( frame_w, window_height / 3 );

	/* Directory tree goes in top pane */
	dir_ctree_w = gui_ctree_add( NULL );
	gtk_paned_add1( GTK_PANED(vpaned_w), dir_ctree_w->parent );
	gtk_widget_show( dir_ctree_w->parent );

	/* File list goes in bottom pane */
	file_clist_w = gui_clist_add( NULL, 3, NULL );
	gtk_paned_add2( GTK_PANED(vpaned_w), file_clist_w->parent );
	gtk_widget_show( file_clist_w->parent );

	/* Left statusbar */
	left_statusbar_w = gui_statusbar_add( left_vbox_w );

	/* Vertical box for everything in the right pane */
	right_vbox_w = gtk_vbox_new( FALSE, 0 );
	gtk_paned_add2( GTK_PANED(hpaned_w), right_vbox_w );
	gtk_widget_show( right_vbox_w );

	/* Horizontal box for viewport and y-scrollbar */
	hbox_w = gui_hbox_add( right_vbox_w, 0 );
	gui_widget_packing( hbox_w, EXPAND, FILL, AT_START );

	/* Main viewport (OpenGL area widget) */
	gl_area_w = gui_gl_area_add( hbox_w );
	gtk_signal_connect( GTK_OBJECT(gl_area_w), "event", GTK_SIGNAL_FUNC(viewport_cb), NULL );

	/* y-scrollbar */
	y_scrollbar_w = gui_vscrollbar_add( hbox_w, NULL );
	G_LIST_APPEND(sw_widget_list, y_scrollbar_w);
	/* x-scrollbar */
	x_scrollbar_w = gui_hscrollbar_add( right_vbox_w, NULL );
	G_LIST_APPEND(sw_widget_list, x_scrollbar_w);

	/* Right statusbar */
	right_statusbar_w = gui_statusbar_add( right_vbox_w );

	/* Bind program icon to main window */
	gui_window_icon_xpm( main_window_w, fsv_icon_xpm );

	/* Attach keybindings */
	gui_keybind( main_window_w, NULL );

	/* Send out the widgets to their respective modules */
	dialog_pass_main_window_widget( main_window_w );
	dirtree_pass_widget( dir_ctree_w );
	filelist_pass_widget( file_clist_w );
	camera_pass_scrollbar_widgets( x_scrollbar_w, y_scrollbar_w );

	/* Showtime! */
	gtk_widget_show( main_window_w );
}
void ZLGtkApplicationWindow::MenuBuilder::processSepartor(ZLMenubar::Separator&) {
	GtkMenuItem *gtkItem = GTK_MENU_ITEM(gtk_separator_menu_item_new());
	gtk_menu_shell_append(GTK_MENU_SHELL(myMenuStack.top()), GTK_WIDGET(gtkItem));
	gtk_widget_show_all(GTK_WIDGET(gtkItem));
}
Exemple #14
0
static void
gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
                                         cairo_t          *cr)
{
  GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
  GtkWidget *widget;
  gint x, y;

  widget = GTK_WIDGET (check_menu_item);

  if (gtk_widget_is_drawable (widget))
    {
      GtkAllocation allocation;
      GtkStyleContext *context;
      guint border_width;
      guint offset;
      guint toggle_size;
      guint toggle_spacing;
      guint horizontal_padding;
      guint indicator_size;
      GtkStateFlags state;
      GtkBorder padding;

      context = gtk_widget_get_style_context (widget);
      state = gtk_widget_get_state_flags (widget);
      gtk_style_context_get_padding (context, state, &padding);

      gtk_widget_get_allocation (widget, &allocation);

      gtk_widget_style_get (widget,
                            "toggle-spacing", &toggle_spacing,
                            "horizontal-padding", &horizontal_padding,
                            "indicator-size", &indicator_size,
                            NULL);

      toggle_size = GTK_MENU_ITEM (check_menu_item)->priv->toggle_size;
      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
      offset = border_width + padding.left + 2;

      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
        {
          x = offset + horizontal_padding +
            (toggle_size - toggle_spacing - indicator_size) / 2;
        }
      else
        {
          x = allocation.width -
            offset - horizontal_padding - toggle_size + toggle_spacing +
            (toggle_size - toggle_spacing - indicator_size) / 2;
        }

      y = (allocation.height - indicator_size) / 2;

      if (priv->active ||
          priv->always_show_toggle ||
          (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_PRELIGHT))
        {
          gtk_style_context_save (context);

          if (priv->inconsistent)
            state |= GTK_STATE_FLAG_INCONSISTENT;
          else if (priv->active)
            state |= GTK_STATE_FLAG_ACTIVE;

          if (!gtk_widget_is_sensitive (widget))
            state |= GTK_STATE_FLAG_INSENSITIVE;

          gtk_style_context_set_state (context, state);

          if (priv->draw_as_radio)
            {
              gtk_style_context_add_class (context, GTK_STYLE_CLASS_RADIO);
              gtk_render_option (context, cr, x, y,
                                 indicator_size, indicator_size);
            }
          else
            {
              gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK);
              gtk_render_check (context, cr, x, y,
                                indicator_size, indicator_size);
            }

          gtk_style_context_restore (context);
        }
    }
}
Exemple #15
0
void pMenu::constructor() {
  gtkMenu = gtk_menu_new();
  widget = gtk_image_menu_item_new_with_mnemonic("");
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), gtkMenu);
  setText(menu.state.text);
}
Exemple #16
0
static void macmenu_construct(AppletType* applet)
{
  MacMenu *mmb = g_slice_new0(MacMenu);
  mmb->applet = applet;
  mmb->screen = wnck_screen_get(gdk_screen_get_number(
      gtk_widget_get_screen(GTK_WIDGET(applet))
      ));
  mmb->mbars_scks = g_hash_table_new(NULL, NULL);
  mmb->title_subs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
  mmb->ts_mtime = 0;

  mmb->basebox = GTK_BOX(gtk_hbox_new(FALSE, 0));
  gtk_container_set_border_width(GTK_CONTAINER(mmb->basebox), 0);
  gtk_container_add(GTK_CONTAINER(applet), GTK_WIDGET(mmb->basebox));

  mmb->label = GTK_LABEL(gtk_label_new(MAIN_LABEL_TEXT));
  PangoAttrList *pattr = pango_attr_list_new();
  PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
  pa->start_index = 0; pa->end_index = 1024;
  pango_attr_list_insert(pattr, pa);
  gtk_label_set_attributes(mmb->label, pattr);
  pango_attr_list_unref(pattr);
  gtk_label_set_ellipsize(mmb->label, PANGO_ELLIPSIZE_END);
  gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10);
  gtk_label_set_single_line_mode(mmb->label, TRUE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->label), FALSE, FALSE, 0);

  mmb->label_space = gtk_event_box_new();
  gtk_widget_set_size_request(mmb->label_space, 8, 1);
  gtk_box_pack_start(mmb->basebox, mmb->label_space, FALSE, FALSE, 0);

  mmb->notebook = GTK_NOTEBOOK(gtk_notebook_new());
  gtk_notebook_set_show_tabs(mmb->notebook, FALSE);
  gtk_notebook_set_show_border(mmb->notebook, FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->notebook), TRUE, TRUE, 0);

  mmb->dummysck = gtk_hbox_new(FALSE, 0);
  gtk_notebook_append_page(mmb->notebook, mmb->dummysck, NULL);

  mmb->mainsck = gtk_hbox_new(FALSE, SHORTCUT_SPACING);
  gtk_notebook_append_page(mmb->notebook, mmb->mainsck, NULL);
  //initialize_mainsck(mmb);

  mmb->button = GTK_BUTTON(gtk_button_new());
  gtk_button_set_relief(mmb->button, GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click(GTK_BUTTON(mmb->button), FALSE);
  gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->button),
                     FALSE, FALSE, 0);

  g_signal_connect(mmb->screen, "active-window-changed",
                   G_CALLBACK(desktop_active_window_changed), mmb);
  g_signal_connect(mmb->screen, "window-opened",
                   G_CALLBACK(desktop_window_opened), mmb);

#ifdef FOR_XFCE
  g_signal_connect(applet, "free-data",
                   G_CALLBACK(macmenu_free_data), mmb);
  g_signal_connect(applet, "size-changed",
                   G_CALLBACK(macmenu_set_size), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(mmb->basebox));
  xfce_panel_plugin_add_action_widget (applet, GTK_WIDGET(mmb->button));
  xfce_panel_plugin_set_expand(applet, TRUE);
  macmenu_set_size(applet, xfce_panel_plugin_get_size(applet), mmb);
  // load config, set popup
  macmenu_load_from_rc(mmb);
  GtkWidget* label_toggle = gtk_check_menu_item_new_with_label("Hide Label");
  g_signal_connect(label_toggle, "toggled", G_CALLBACK(on_label_toggled), mmb);
  gtk_widget_show(label_toggle);
  gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(label_toggle), mmb->hide_label);
  gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(label_toggle));
  xfce_panel_plugin_menu_insert_item(mmb->applet, GTK_MENU_ITEM(label_toggle));

#elif FOR_GNOME
  g_signal_connect(applet, "destroy", G_CALLBACK(macmenu_free_data), mmb);
  // setup panel applet
  gtk_widget_show_all(GTK_WIDGET(applet));
  g_signal_connect(GTK_WIDGET(mmb->button), "pressed",
                   G_CALLBACK(on_button_pressed), mmb);
  panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MAJOR);
  macmenu_set_size(applet, panel_applet_get_size(applet), mmb);
  // load config, set popup
  mmb->gconf = gconf_client_get_default();
  macmenu_load_from_gconf(mmb);
  macmenu_write_gconf(mmb);
  static const char toggle_menu_xml [] =
   "<popup name=\"button3\">\n"
   "   <menuitem name=\"hide_label\" "
   "             verb=\"hide_label\" "
   "           _label=\"_Hide Label\"\n"
   "             type=\"toggle\"/>\n"
   "</popup>\n";
  static const BonoboUIVerb toggle_menu_verbs[] =
  {
    BONOBO_UI_VERB_END
  };
  panel_applet_setup_menu(mmb->applet, toggle_menu_xml, toggle_menu_verbs, mmb);
  BonoboUIComponent* popup_component = panel_applet_get_popup_component(mmb->applet);
  bonobo_ui_component_set_prop(popup_component, "/commands/hide_label",
                               "state", mmb->hide_label ? "1": "0", NULL);
  bonobo_ui_component_add_listener(panel_applet_get_popup_component(mmb->applet),
                                   "hide_label",
                                   (BonoboUIListenerFn) on_label_toggled,
                                   mmb);
  on_label_toggled(NULL, NULL, 0, NULL, mmb);
#endif // FOR_XFCE/FOR_GNOME

  add_all(mmb);
  XSetErrorHandler(handle_x_error);
}
Exemple #17
0
static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pkd, gint x, gint y)
{
	GtkWidget *menu;
	GtkWidget *item;
	GtkWidget *submenu;
        GtkTreeViewDropPosition pos;

        if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath);
        pkd->click_tpath = NULL;
	gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(pkd->keyword_treeview), x, y, &pkd->click_tpath, &pos);

	menu = popup_menu_short_lived();

	menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd);

	menu_item_add_divider(menu);

	menu_item_add(menu, _("Add keyword to all selected images"), G_CALLBACK(bar_pane_keywords_add_to_selected_cb), pkd);

	menu_item_add_divider(menu);

	if (pkd->click_tpath)
		{
		/* for the entry */
		gchar *text;
		gchar *mark;
		gint i;

		GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview));

		GtkTreeIter iter;
                gtk_tree_model_get_iter(model, &iter, pkd->click_tpath);
		gchar *name;

		gtk_tree_model_get(model, &iter, FILTER_KEYWORD_COLUMN_NAME, &name,
						 FILTER_KEYWORD_COLUMN_MARK, &mark, -1);

		text = g_strdup_printf(_("Hide \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_hide_cb), pkd);
		g_free(text);

		submenu = gtk_menu_new();
		for (i = 0; i < FILEDATA_MARKS_SIZE; i++)
			{
			text = g_strdup_printf(_("Mark %d"), i + 1);
			item = menu_item_add(submenu, text, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
			g_object_set_data(G_OBJECT(item), "mark", GINT_TO_POINTER(i + 1));
			g_free(text);
			}
		text = g_strdup_printf(_("Connect \"%s\" to mark"), name);
		item = menu_item_add(menu, text, NULL, NULL);
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
		g_free(text);

		menu_item_add_divider(menu);

		text = g_strdup_printf(_("Edit \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_edit_dialog_cb), pkd);
		g_free(text);
		text = g_strdup_printf(_("Remove \"%s\""), name);
		menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_delete_cb), pkd);
		g_free(text);


		if (mark && mark[0])
			{
			text = g_strdup_printf(_("Disconnect \"%s\" from mark %s"), name, mark);
			menu_item_add_stock(menu, text, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_keywords_connect_mark_cb), pkd);
			g_free(text);
			}

		menu_item_add_divider(menu);
		g_free(mark);
		g_free(name);
		}
	/* for the pane */


	menu_item_add(menu, _("Expand checked"), G_CALLBACK(bar_pane_keywords_expand_checked_cb), pkd);
	menu_item_add(menu, _("Collapse unchecked"), G_CALLBACK(bar_pane_keywords_collapse_unchecked_cb), pkd);
	menu_item_add(menu, _("Hide unchecked"), G_CALLBACK(bar_pane_keywords_hide_unchecked_cb), pkd);
	menu_item_add(menu, _("Show all"), G_CALLBACK(bar_pane_keywords_show_all_cb), pkd);

	submenu = gtk_menu_new();
	item = menu_item_add(menu, _("On any change"), NULL, NULL);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);

	menu_item_add_check(submenu, _("Expand checked"), pkd->expand_checked, G_CALLBACK(bar_pane_keywords_expand_checked_toggle_cb), pkd);
	menu_item_add_check(submenu, _("Collapse unchecked"), pkd->collapse_unchecked, G_CALLBACK(bar_pane_keywords_collapse_unchecked_toggle_cb), pkd);
	menu_item_add_check(submenu, _("Hide unchecked"), pkd->hide_unchecked, G_CALLBACK(bar_pane_keywords_hide_unchecked_toggle_cb), pkd);

	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
}
Exemple #18
0
int 
main (int argc, char **argv)
{
  static GtkWidget *window = NULL;
  GtkWidget *box1;
  GtkWidget *box2;
  GtkWidget *button;
  GtkWidget *optionmenu;
  GtkWidget *separator;

  gtk_init (&argc, &argv);
  
  if (!window)
    {
      GtkWidget *menubar;
      GtkWidget *menu;
      GtkWidget *submenu;
      GtkWidget *menuitem;
      GtkAccelGroup *accel_group;
      
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      
      g_signal_connect (window, "destroy",
			G_CALLBACK(gtk_main_quit), NULL);
      g_signal_connect (window, "delete-event",
			G_CALLBACK (gtk_true), NULL);
      
      accel_group = gtk_accel_group_new ();
      gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);

      gtk_window_set_title (GTK_WINDOW (window), "menus");
      gtk_container_set_border_width (GTK_CONTAINER (window), 0);
      
      
      box1 = gtk_vbox_new (FALSE, 0);
      gtk_container_add (GTK_CONTAINER (window), box1);
      gtk_widget_show (box1);
      
      menubar = gtk_menu_bar_new ();
      gtk_box_pack_start (GTK_BOX (box1), menubar, FALSE, TRUE, 0);
      gtk_widget_show (menubar);
      
      menu = create_menu (2, TRUE);
      
      menuitem = gtk_menu_item_new_with_label ("test\nline2");
      gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
      gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
      gtk_widget_show (menuitem);

      
      menuitem = gtk_menu_item_new_with_label ("dynamic");
      submenu = create_menu (3, TRUE);
      gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
      gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
      gtk_widget_show (menuitem);
      
      g_timeout_add (250, change_item, submenu);

      menuitem = gtk_menu_item_new_with_label ("bar");
      gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (4, TRUE));
      gtk_menu_item_set_right_justified (GTK_MENU_ITEM (menuitem), TRUE);
      gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
      gtk_widget_show (menuitem);
      
      box2 = gtk_vbox_new (FALSE, 10);
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
      gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
      gtk_widget_show (box2);
      
      menu = create_menu (1, FALSE);
      gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
      
      menuitem = gtk_separator_menu_item_new ();
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
      gtk_widget_show (menuitem);
      
      menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me");
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
      gtk_widget_show (menuitem);
      gtk_widget_add_accelerator (menuitem,
				  "activate",
				  accel_group,
				  GDK_F1,
				  0,
				  GTK_ACCEL_VISIBLE);
      menuitem = gtk_check_menu_item_new_with_label ("Accelerator Locked");
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
      gtk_widget_show (menuitem);
      gtk_widget_add_accelerator (menuitem,
				  "activate",
				  accel_group,
				  GDK_F2,
				  0,
				  GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
      menuitem = gtk_check_menu_item_new_with_label ("Accelerators Frozen");
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
      gtk_widget_show (menuitem);
      gtk_widget_add_accelerator (menuitem,
				  "activate",
				  accel_group,
				  GDK_F2,
				  0,
				  GTK_ACCEL_VISIBLE);
      gtk_widget_add_accelerator (menuitem,
				  "activate",
				  accel_group,
				  GDK_F3,
				  0,
				  GTK_ACCEL_VISIBLE);
      
      optionmenu = gtk_option_menu_new ();
      gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
      gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 3);
      gtk_box_pack_start (GTK_BOX (box2), optionmenu, TRUE, TRUE, 0);
      gtk_widget_show (optionmenu);

      separator = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
      gtk_widget_show (separator);

      box2 = gtk_vbox_new (FALSE, 10);
      gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
      gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
      gtk_widget_show (box2);

      button = gtk_button_new_with_label ("close");
      g_signal_connect_swapped (button, "clicked",
				G_CALLBACK(gtk_widget_destroy), window);
      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
      GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
      gtk_widget_grab_default (button);
      gtk_widget_show (button);
    }

  if (!GTK_WIDGET_VISIBLE (window))
    {
      gtk_widget_show (window);
    }
  else
    {
      gtk_widget_destroy (window);
      window = NULL;
    }

  gtk_main ();

  return 0;
}
Exemple #19
0
/**
 * main routine, parses args and reads from console
 */
int main(int argc, char *argv[])
{
	GtkWidget *menubar, *menu, *menuitem, *vbox;
	GtkWidget *dummMenu, *guestMenu, *switchMenu;
	enumerator_t *enumerator;
	guest_t *guest;

	library_init(NULL);
	gtk_init(&argc, &argv);

	pages = linked_list_create();
	dumm = dumm_create(NULL);

	/* setup window */
	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(quit), NULL);
	gtk_window_set_title(GTK_WINDOW (window), "Dumm");
	gtk_window_set_default_size(GTK_WINDOW (window), 1000, 500);
	g_signal_connect(G_OBJECT(vte_reaper_get()), "child-exited",
					 G_CALLBACK(child_exited), NULL);

	/* add vbox with menubar, notebook */
	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	menubar = gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
	notebook = gtk_notebook_new();
	g_object_set(G_OBJECT(notebook), "homogeneous", TRUE, NULL);
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_BOTTOM);
	gtk_container_add(GTK_CONTAINER(vbox), notebook);

	/* Dumm menu */
	menu = gtk_menu_new();
	dummMenu = gtk_menu_item_new_with_mnemonic("_Dumm");
	gtk_menu_bar_append(GTK_MENU_BAR(menubar), dummMenu);
	gtk_widget_show(dummMenu);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(dummMenu), menu);

	/* Dumm -> exit */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(quit), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest menu */
	menu = gtk_menu_new();
	guestMenu = gtk_menu_item_new_with_mnemonic("_Guest");
	gtk_menu_bar_append(GTK_MENU_BAR(menubar), guestMenu);
	gtk_widget_show(guestMenu);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(guestMenu), menu);

	/* Guest -> new */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(create_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> delete */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(delete_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	menuitem = gtk_separator_menu_item_new();
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> start */
	menuitem = gtk_menu_item_new_with_mnemonic("_Start");
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(start_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> startall */
	menuitem = gtk_menu_item_new_with_mnemonic("Start _all");
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(start_all_guests), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> stop */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_STOP, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(stop_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	menuitem = gtk_separator_menu_item_new();
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> connect */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_CONNECT, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(connect_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Guest -> disconnect */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DISCONNECT, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(disconnect_guest), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_set_sensitive(menuitem, FALSE);
	gtk_widget_show(menuitem);

	/* Switch menu */
	menu = gtk_menu_new();
	switchMenu = gtk_menu_item_new_with_mnemonic("_Switch");
	gtk_menu_bar_append(GTK_MENU_BAR(menubar), switchMenu);
	gtk_widget_show(switchMenu);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(switchMenu), menu);

	/* Switch -> new */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(create_switch), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_show(menuitem);

	/* Switch -> delete */
	menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL);
	g_signal_connect(G_OBJECT(menuitem), "activate",
					 G_CALLBACK(delete_switch), NULL);
	gtk_menu_append(GTK_MENU(menu), menuitem);
	gtk_widget_set_sensitive(menuitem, FALSE);
	gtk_widget_show(menuitem);

	/* show widgets */
	gtk_widget_show(menubar);
	gtk_widget_show(notebook);
	gtk_widget_show(vbox);
	gtk_widget_show(window);

	/* fill notebook with guests */
	enumerator = dumm->create_guest_enumerator(dumm);
	while (enumerator->enumerate(enumerator, (void**)&guest))
	{
		create_page(guest);
	}
	enumerator->destroy(enumerator);

	gtk_main();

	dumm->destroy(dumm);
	pages->destroy_function(pages, g_free);

	library_deinit();
	return 0;
}
Exemple #20
0
void ui_set_menu() {

    mwin->menu = gtk_menu_bar_new();

    GtkAccelGroup *group_file = ui_set_menu_item(&(mwin->menu_file), 
        &(mwin->menu_file_item), "_File");
    GtkAccelGroup *group_edit = ui_set_menu_item(&(mwin->menu_edit), 
        &(mwin->menu_edit_item), "_Edit");
    GtkAccelGroup *group_help = ui_set_menu_item(&(mwin->menu_help), 
        &(mwin->menu_help_item), "_Help");

    /* create submenu items */
    mwin->menu_file_item_open = gtk_menu_item_new_with_mnemonic("_Open");
    mwin->menu_file_item_compare = gtk_menu_item_new_with_mnemonic("_Compare To");
    mwin->menu_file_item_exit = gtk_menu_item_new_with_mnemonic("_Exit");
    mwin->menu_file_item_space = gtk_separator_menu_item_new();
    mwin->menu_edit_item_update = gtk_menu_item_new_with_mnemonic("_Update");
    mwin->menu_edit_item_purge = gtk_menu_item_new_with_mnemonic("_Purge Lists");
    mwin->menu_help_item_about = gtk_menu_item_new_with_mnemonic("_About");

    /* add accelerator keys to menu */
    gtk_widget_add_accelerator(mwin->menu_file_item_open, "activate", 
        group_file, GDK_KEY_O, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(mwin->menu_file_item_compare, "activate", 
        group_file, GDK_KEY_L, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(mwin->menu_file_item_exit, "activate", 
        group_file, GDK_KEY_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(mwin->menu_edit_item_update, "activate", 
        group_edit, GDK_KEY_U, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(mwin->menu_edit_item_purge, "activate", 
        group_edit, GDK_KEY_P, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator(mwin->menu_help_item_about, "activate", 
        group_help, GDK_KEY_A, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);

    /* append menu items to menus */
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_file), mwin->menu_file_item_open);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_file), mwin->menu_file_item_compare);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_file), mwin->menu_file_item_space);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_file), mwin->menu_file_item_exit);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_edit), mwin->menu_edit_item_update);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_edit), mwin->menu_edit_item_purge);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu_help), mwin->menu_help_item_about);

    /* attach callback functions to menu-items */
    g_signal_connect_swapped(G_OBJECT(mwin->menu_file_item_open), 
        "activate", G_CALLBACK(menu_signal_open), (gpointer)nb_lists_mov_tab);
    g_signal_connect_swapped(G_OBJECT(mwin->menu_file_item_compare), 
        "activate", G_CALLBACK(menu_signal_open), (gpointer)nb_lists_lst_tab);
    g_signal_connect_swapped(G_OBJECT(mwin->menu_file_item_exit), 
        "activate", G_CALLBACK(menu_signal_quit), (gpointer)mwin->main);
    g_signal_connect_swapped(G_OBJECT(mwin->menu_edit_item_update), 
        "activate", G_CALLBACK(menu_signal_update), (gpointer)mwin->main);
    g_signal_connect_swapped(G_OBJECT(mwin->menu_edit_item_purge), 
        "activate", G_CALLBACK(menu_signal_purge), (gpointer)mwin->main);
    g_signal_connect_swapped(G_OBJECT(mwin->menu_help_item_about), 
        "activate", G_CALLBACK(menu_signal_about), (gpointer)mwin->main);

    /* add submenus to menu items */
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(mwin->menu_file_item), 
        mwin->menu_file);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(mwin->menu_edit_item), 
        mwin->menu_edit);
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(mwin->menu_help_item), 
        mwin->menu_help);

    /* add to main menubar */
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu), mwin->menu_file_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu), mwin->menu_edit_item);
    gtk_menu_shell_append(GTK_MENU_SHELL(mwin->menu), mwin->menu_help_item);
}
void open_mainwindow ()
{
	mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(mainwin), GTK_WIN_POS_CENTER);
  	gtk_window_set_default_size(GTK_WINDOW(mainwin), 250, 200);
  	gtk_window_set_title(GTK_WINDOW(mainwin), "Bakamoona v 0.1");
	gtk_window_set_icon(GTK_WINDOW(mainwin), create_pixbuf("images/bkm.png"));

	layout = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (mainwin), layout);

	menubar = gtk_menu_bar_new ();

/*
  System | Maintenance | Finance | Search | Statistics | About
*/

    // System
    sysmenu = gtk_menu_new();
    sys_menu_item = gtk_menu_item_new_with_label ("System");
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(sys_menu_item), sysmenu);

    // adding bus
    bus_item = gtk_menu_item_new_with_label ("Bus");
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), bus_item);

    busmenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(bus_item), busmenu);

    addbus = gtk_menu_item_new_with_label ("Add Bus");
    updatebus = gtk_menu_item_new_with_label ("Update Bus");
    deletebus = gtk_menu_item_new_with_label ("Delete Bus");

    gtk_menu_shell_append (GTK_MENU_SHELL(busmenu), addbus);
    gtk_menu_shell_append (GTK_MENU_SHELL(busmenu), updatebus);
    gtk_menu_shell_append (GTK_MENU_SHELL(busmenu), deletebus);

    // adding owner
    owner_item = gtk_menu_item_new_with_label ("Owner");
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), owner_item);

    ownermenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(owner_item), ownermenu);

    addowner = gtk_menu_item_new_with_label ("Add Owner");
    updateowner = gtk_menu_item_new_with_label ("Update Owner");
    deleteowner = gtk_menu_item_new_with_label ("Delete Owner");

    gtk_menu_shell_append (GTK_MENU_SHELL(ownermenu), addowner);
    gtk_menu_shell_append (GTK_MENU_SHELL(ownermenu), updateowner);
    gtk_menu_shell_append (GTK_MENU_SHELL(ownermenu), deleteowner);

    // adding sparepart 
    sp_item = gtk_menu_item_new_with_label ("Spare Part");
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), sp_item);

    spmenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(sp_item), spmenu);

    addsp = gtk_menu_item_new_with_label ("Add Spare Part");
    updatesp = gtk_menu_item_new_with_label ("Update Spare Part");
    deletesp = gtk_menu_item_new_with_label ("Delete Spare Part");

    gtk_menu_shell_append (GTK_MENU_SHELL(spmenu), addsp);
    gtk_menu_shell_append (GTK_MENU_SHELL(spmenu), updatesp);
    gtk_menu_shell_append (GTK_MENU_SHELL(spmenu), deletesp);
    
    // adding worker
    worker_item = gtk_menu_item_new_with_label ("Worker");
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), worker_item);

    workermenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(worker_item), workermenu);

    addworker = gtk_menu_item_new_with_label ("Add Worker");
    updateworker = gtk_menu_item_new_with_label ("Update Worker");
    deleteworker = gtk_menu_item_new_with_label ("Delete Worker");

    gtk_menu_shell_append (GTK_MENU_SHELL(workermenu), addworker);
    gtk_menu_shell_append (GTK_MENU_SHELL(workermenu), updateworker);
    gtk_menu_shell_append (GTK_MENU_SHELL(workermenu), deleteworker);
    
    // adding packages
    package_item = gtk_menu_item_new_with_label ("Package");
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), package_item);

    packagemenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(package_item), packagemenu);

    addpackage = gtk_menu_item_new_with_label ("Add Package");
    updatepackage = gtk_menu_item_new_with_label ("Update Package");
    deletepackage = gtk_menu_item_new_with_label ("Delete Package");

    gtk_menu_shell_append (GTK_MENU_SHELL(packagemenu), addpackage);
    gtk_menu_shell_append (GTK_MENU_SHELL(packagemenu), updatepackage);
    gtk_menu_shell_append (GTK_MENU_SHELL(packagemenu), deletepackage);

	sep = gtk_separator_menu_item_new();
    quit = gtk_menu_item_new_with_label("Quit");

    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), sep);
    gtk_menu_shell_append (GTK_MENU_SHELL(sysmenu), quit);
        
    gtk_menu_shell_append (GTK_MENU_SHELL(menubar), sys_menu_item);

	mntmenu = gtk_menu_new();
    mnt_menu_item = gtk_menu_item_new_with_label ("Maintenance");
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(mnt_menu_item), mntmenu);

	gtk_menu_shell_append (GTK_MENU_SHELL(menubar), mnt_menu_item);

	addmnt = gtk_menu_item_new_with_label ("Add Maintenance");
    updatemnt = gtk_menu_item_new_with_label ("Update Maintenance");

	gtk_menu_shell_append (GTK_MENU_SHELL(mntmenu), addmnt);
	gtk_menu_shell_append (GTK_MENU_SHELL(mntmenu), updatemnt);

	//

	finmenu = gtk_menu_new();
    fin_menu_item = gtk_menu_item_new_with_label ("Finance");
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(fin_menu_item), finmenu);

	gtk_menu_shell_append (GTK_MENU_SHELL(menubar), fin_menu_item);

	addfin = gtk_menu_item_new_with_label ("Add Bill");
    updatefin = gtk_menu_item_new_with_label ("Update Bill");

	gtk_menu_shell_append (GTK_MENU_SHELL(finmenu), addfin);
	gtk_menu_shell_append (GTK_MENU_SHELL(finmenu), updatefin);
	
	//

	searchmenu = gtk_menu_new();
    search_menu_item = gtk_menu_item_new_with_label ("Search");
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(search_menu_item), searchmenu);

	gtk_menu_shell_append (GTK_MENU_SHELL(menubar), search_menu_item);

	search_bus = gtk_menu_item_new_with_label ("Bus");
	search_own = gtk_menu_item_new_with_label ("Owner");
	search_worker = gtk_menu_item_new_with_label ("Worker");
	search_sp = gtk_menu_item_new_with_label ("Spare Part");
	search_bill = gtk_menu_item_new_with_label ("Bill");
	search_mnt = gtk_menu_item_new_with_label ("Maintenance");
	
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_bus);
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_own);
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_worker);
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_sp);
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_bill);
	gtk_menu_shell_append (GTK_MENU_SHELL(searchmenu), search_mnt);

	//

	aboutmenu = gtk_menu_new();
    about_menu_item = gtk_menu_item_new_with_label ("About");
    gtk_menu_item_set_submenu (GTK_MENU_ITEM(about_menu_item), aboutmenu);

	gtk_menu_shell_append (GTK_MENU_SHELL(menubar), about_menu_item);
	
	devteam = gtk_menu_item_new_with_label ("About DEV team");
	gtk_menu_shell_append (GTK_MENU_SHELL(aboutmenu), devteam);

// end

  	gtk_box_pack_start (GTK_BOX(layout), menubar, FALSE, FALSE, 0);

	toolbar = gtk_toolbar_new();
 	gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
	gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);

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

	new_tool = gtk_tool_button_new_from_stock(GTK_STOCK_NEW);
  	gtk_toolbar_insert (GTK_TOOLBAR(toolbar), new_tool, -1);

	open_tool = gtk_tool_button_new_from_stock(GTK_STOCK_OPEN);
  	gtk_toolbar_insert (GTK_TOOLBAR(toolbar), open_tool, -1);

	save_tool = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
  	gtk_toolbar_insert (GTK_TOOLBAR(toolbar), save_tool, -1);

	gtk_box_pack_start (GTK_BOX(layout), toolbar, FALSE, FALSE, 0);

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

	g_signal_connect(G_OBJECT(addbus), "activate",
        G_CALLBACK(add_bus_clicked), NULL);
    g_signal_connect(G_OBJECT(addworker), "activate",
        G_CALLBACK(add_worker_clicked), NULL);
	g_signal_connect(G_OBJECT(addowner), "activate",
        G_CALLBACK(add_owner_clicked), NULL);
	g_signal_connect(G_OBJECT(addsp), "activate",
        G_CALLBACK(add_sparepart_clicked), NULL);
  	g_signal_connect(G_OBJECT(quit), "activate",
        G_CALLBACK(gtk_main_quit), NULL);
	g_signal_connect(G_OBJECT(addmnt), "activate",
        G_CALLBACK(add_maintenance_clicked), NULL);

        g_signal_connect(G_OBJECT(addfin), "activate",
        G_CALLBACK(add_bill_clicked), NULL);

        g_signal_connect(G_OBJECT(addpackage), "activate",
        G_CALLBACK(add_package_clicked), NULL);

	gtk_window_maximize (GTK_WINDOW(mainwin));
  	gtk_widget_show_all(mainwin);

}
Exemple #22
0
bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
{
    GtkWidget *menuItem;

    wxString text;
    GtkLabel* label = NULL;

    if ( mitem->IsSeparator() )
    {
        // TODO
        menuItem = gtk_menu_item_new();
    }
    else if (mitem->GetBitmap().Ok())
    {
        text = mitem->GetText();
        const wxBitmap *bitmap = &mitem->GetBitmap();

        // TODO
        wxUnusedVar(bitmap);
        menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
        label = GTK_LABEL( GTK_BIN(menuItem)->child );

        m_prevRadio = NULL;
    }
    else // a normal item
    {
        // text has "_" instead of "&" after mitem->SetText() so don't use it
        text =  mitem->GetText() ;

        switch ( mitem->GetKind() )
        {
            case wxITEM_CHECK:
            {
                menuItem = gtk_check_menu_item_new_with_label( wxGTK_CONV( text ) );
                label = GTK_LABEL( GTK_BIN(menuItem)->child );
                // set new text
                gtk_label_set_text( label, wxGTK_CONV( text ) );
                m_prevRadio = NULL;
                break;
            }

            case wxITEM_RADIO:
            {
                GSList *group = NULL;
                if ( m_prevRadio == NULL )
                {
                    // start of a new radio group
                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
                    label = GTK_LABEL( GTK_BIN(menuItem)->child );
                    // set new text
                    gtk_label_set_text( label, wxGTK_CONV( text ) );
                }
                else // continue the radio group
                {
                    group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) );
                    label = GTK_LABEL( GTK_BIN(menuItem)->child );
                }
                break;
            }

            default:
                wxFAIL_MSG( _T("unexpected menu item kind") );
                // fall through

            case wxITEM_NORMAL:
            {
                menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) );
                label = GTK_LABEL( GTK_BIN(menuItem)->child );
                m_prevRadio = NULL;
                break;
            }
        }

    }

    guint accel_key;
    GdkModifierType accel_mods;
    wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) );

    // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() );
    gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
    if (accel_key != 0)
    {
        gtk_widget_add_accelerator (GTK_WIDGET(menuItem),
                                    "activate",
                                    m_accel,
                                    accel_key,
                                    accel_mods,
                                    GTK_ACCEL_VISIBLE);
    }

    if (pos == -1)
        gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem);
    else
        gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos);

    gtk_widget_show( menuItem );

    if ( !mitem->IsSeparator() )
    {
        wxASSERT_MSG( menuItem, wxT("invalid menuitem") );

        gtk_signal_connect( GTK_OBJECT(menuItem), "select",
                            GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
                            (gpointer)this );

        gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
                            GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
                            (gpointer)this );

        if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK )
        {
            gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );

            gtk_widget_show( mitem->GetSubMenu()->m_menu );

            // if adding a submenu to a menu already existing in the menu bar, we
            // must set invoking window to allow processing events from this
            // submenu
            if ( m_invokingWindow )
                wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow);
        }
        else
        {
            gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
                                GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
                                (gpointer)this );
        }

        guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
        if (accel_key != GDK_VoidSymbol)
        {
            gtk_widget_add_accelerator (menuItem,
                                        "activate_item",
                                        gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)),
                                        accel_key,
                                        GDK_MOD1_MASK,
                                        GTK_ACCEL_LOCKED);
        }
    }

    mitem->SetMenuItem(menuItem);

    if (ms_locked)
    {
        // This doesn't even exist!
        // gtk_widget_lock_accelerators(mitem->GetMenuItem());
    }

    return true;
}
bool WebPopupMenuProxyGtk::typeAheadFind(GdkEventKey* event)
{
    // If we were given a non-printable character just skip it.
    gunichar unicodeCharacter = gdk_keyval_to_unicode(event->keyval);
    if (!g_unichar_isprint(unicodeCharacter)) {
        resetTypeAheadFindState();
        return false;
    }

    glong charactersWritten;
    GUniquePtr<gunichar2> utf16String(g_ucs4_to_utf16(&unicodeCharacter, 1, nullptr, &charactersWritten, nullptr));
    if (!utf16String) {
        resetTypeAheadFindState();
        return false;
    }

    // If the character is the same as the last character, the user is probably trying to
    // cycle through the menulist entries. This matches the WebCore behavior for collapsed menulists.
    static const uint32_t searchTimeoutMs = 1000;
    bool repeatingCharacter = unicodeCharacter != m_previousKeyEventCharacter;
    if (event->time - m_previousKeyEventTimestamp > searchTimeoutMs)
        m_currentSearchString = String(reinterpret_cast<UChar*>(utf16String.get()), charactersWritten);
    else if (repeatingCharacter)
        m_currentSearchString.append(String(reinterpret_cast<UChar*>(utf16String.get()), charactersWritten));

    m_previousKeyEventTimestamp = event->time;
    m_previousKeyEventCharacter = unicodeCharacter;

    GUniquePtr<GList> children(gtk_container_get_children(GTK_CONTAINER(m_popup)));
    if (!children)
        return true;

    // We case fold before searching, because strncmp does not handle non-ASCII characters.
    GUniquePtr<gchar> searchStringWithCaseFolded(g_utf8_casefold(m_currentSearchString.utf8().data(), -1));
    size_t prefixLength = strlen(searchStringWithCaseFolded.get());

    // If a menu item has already been selected, start searching from the current
    // item down the list. This will make multiple key presses of the same character
    // advance the selection.
    GList* currentChild = children.get();
    if (m_currentlySelectedMenuItem) {
        currentChild = g_list_find(children.get(), m_currentlySelectedMenuItem);
        if (!currentChild) {
            m_currentlySelectedMenuItem = nullptr;
            currentChild = children.get();
        }

        // Repeating characters should iterate.
        if (repeatingCharacter) {
            if (GList* nextChild = g_list_next(currentChild))
                currentChild = nextChild;
        }
    }

    GList* firstChild = currentChild;
    do {
        currentChild = g_list_next(currentChild);
        if (!currentChild)
            currentChild = children.get();

        GUniquePtr<gchar> itemText(g_utf8_casefold(gtk_menu_item_get_label(GTK_MENU_ITEM(currentChild->data)), -1));
        if (!strncmp(searchStringWithCaseFolded.get(), itemText.get(), prefixLength)) {
            gtk_menu_shell_select_item(GTK_MENU_SHELL(m_popup), GTK_WIDGET(currentChild->data));
            break;
        }
    } while (currentChild != firstChild);

    return true;
}
Exemple #24
0
void dev_select_rescan(GtkAction *action, GtkWindow *parent)
{
	GtkComboBox *dev = g_object_get_data(G_OBJECT(parent), "devcombo");
	g_return_if_fail(dev != NULL);
	GtkListStore *devlist = GTK_LIST_STORE(gtk_combo_box_get_model(dev));
	GtkTreeIter iter;
	struct sr_device *device;
	struct sr_device_instance *sdi;
	gchar *sdevname = NULL;
	GSList *devices, *l;
	GtkUIManager *ui = g_object_get_data(G_OBJECT(parent), "ui_manager");
	GtkWidget *menuitem = gtk_ui_manager_get_widget(ui,
					"/menubar/DevMenu/DevSelectMenu");
	GtkMenuShell *devmenu = GTK_MENU_SHELL(gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem)));
	GSList *radiolist = NULL;

	(void)action;

	/* Make a copy of the selected device's short name for comparison.
	 * We wish to select the same device after the refresh if possible.
	 */
	if (gtk_combo_box_get_active_iter(dev, &iter)) {
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 1, &device, -1);
		/* FIXME: Use something other than device->plugin->name */
		sdevname = g_strdup(device->plugin->name);
	}

	/* Destroy the old menu items */
	if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter)) do {
		GtkMenuItem *item;
		gtk_tree_model_get(GTK_TREE_MODEL(devlist), &iter, 2, &item, -1);
		gtk_object_destroy(GTK_OBJECT(item));
	} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter));

	gtk_list_store_clear(devlist);

	/* Scan for new devices and update our list */
	/* TODO: Fix this in libsigrok first. */
	/*sr_device_scan();*/
	devices = sr_device_list();
	for (l = devices; l; l = l->next) {
		device = l->data;
		sdi = GET_DEVICE_INSTANCE(device);
		gchar *name = sdi->model ? sdi->model : sdi->vendor;
		if (!name)
			name = "(unknown)";

		menuitem = gtk_radio_menu_item_new_with_label(radiolist, name);
		gtk_widget_show(GTK_WIDGET(menuitem));
		if (!radiolist)
			radiolist = gtk_radio_menu_item_get_group(
					GTK_RADIO_MENU_ITEM(menuitem));
		g_signal_connect(menuitem, "toggled",
				G_CALLBACK(dev_menuitem_toggled), dev);
		gtk_menu_shell_prepend(devmenu, menuitem);

		gtk_list_store_append(devlist, &iter);
		gtk_list_store_set(devlist, &iter,
				0, name,
				1, device,
				2, menuitem,
				-1);

		if (sdevname && g_str_equal(sdevname, device->plugin->name))
			gtk_combo_box_set_active_iter(dev, &iter);
	}
	if (sdevname)
		g_free(sdevname);

	/* Select a default if nothing selected */
	if (!gtk_combo_box_get_active_iter(dev, &iter)) {
		if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(devlist), &iter))
			return;
		/* Skip demo if there's another available */
		GtkTreeIter first = iter;
		if (gtk_tree_model_iter_next(GTK_TREE_MODEL(devlist), &iter))
			gtk_combo_box_set_active_iter(dev, &iter);
		else
			gtk_combo_box_set_active_iter(dev, &first);
	}
}
Exemple #25
0
struct menu *
gui_gtk_menu_new(struct container *co, GtkWidget **widget)
{
	struct menu *this=g_new0(struct menu, 1);

	this->gui=g_new0(struct menu_gui,1);
        this->gui->co=co;


	GtkWidget *menu,*item,*menu2,*item2,*menu3,*clock;

	menu=gtk_menu_bar_new();
	item=gtk_menu_item_new_with_label("Goto");
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	{
		menu2=gtk_menu_new();
		item2=gtk_menu_item_new_with_label("Abensberg");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_goto_abensberg), this);

		item2=gtk_menu_item_new_with_label("Regensburg");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_goto_regensburg), this);
		item2=gtk_menu_item_new_with_label("Problem");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_goto_problem), this);
	}
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2);

	item=gtk_menu_item_new_with_label("Window");
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	{
		menu2=gtk_menu_new();

		item2=gtk_menu_item_new_with_label("Clone");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_clone), this);

		item2=gtk_menu_item_new_with_label("Command");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_command), this);

		item2=gtk_menu_item_new_with_label("Visible Blocks");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_visible_blocks), co);

		item2=gtk_menu_item_new_with_label("Visible Towns");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_visible_towns), co);

		item2=gtk_menu_item_new_with_label("Visible Polys");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_visible_polys), co);


		item2=gtk_menu_item_new_with_label("Visible Streets");
		gtk_menu_append (GTK_MENU(menu2), item2);
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_window_visible_streets), co);

		menu_item(this, menu2, "Visible Points", menu_window_visible_points);

		item2=gtk_menu_item_new_with_label("Exit");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (exit), this);
	}
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2);

	item=gtk_menu_item_new_with_label("Map");
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	{
		menu2=gtk_menu_new();

		item2=gtk_menu_item_new_with_label("Compare");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_map_compare), this);

		item2=gtk_menu_item_new_with_label("Distances");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_map_distances), this);
	}
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2);

	item=gtk_menu_item_new_with_label("Route");
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	{
		menu2=gtk_menu_new();

		item2=gtk_menu_item_new_with_label("Start");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (route_start), co);

		item2=gtk_menu_item_new_with_label("Trace");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (route_trace), co);

		item2=gtk_menu_item_new_with_label("Update");
		gtk_menu_append (GTK_MENU(menu2), item2); 
		gtk_signal_connect_object(GTK_OBJECT(item2), "activate",
			GTK_SIGNAL_FUNC (menu_route_update), this);
	}
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2);

	item=gtk_menu_item_new_with_label("Destinations");
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	menu2=gtk_menu_new();

	item2=gtk_menu_item_new_with_label("Last Destinations");
	gtk_menu_append (GTK_MENU(menu2), item2); 
	menu3=gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item2), menu3);

	item2=gtk_menu_item_new_with_label("Address");
	gtk_menu_append (GTK_MENU(menu2), item2); 

	{
		FILE *file;
		char buffer[8192];
		double lat,lng,lat_deg,lng_deg;
		char lat_c,lng_c;
		struct destination *dest;
		int pos,len;
		char *utf8,*text,*tok,*label;
		GList *list;
	
		file=fopen("locations.txt","r");
		while (fgets(buffer,8192,file)) {
			dest=malloc(sizeof(*dest));
			dest->co=co;
			len=strlen(buffer)-1;
			while (len >= 0 && buffer[len] == '\n') {
				buffer[len]='\0';
			}
			sscanf(buffer,"%lf %c %lf %c %n",&lat, &lat_c, &lng, &lng_c, &pos);
		
			lat_deg=floor(lat/100);
			lat-=lat_deg*100;
			lat_deg+=lat/60;     	

			lng_deg=floor(lng/100);
			lng-=lng_deg*100;
			lng_deg+=lng/60;          

			transform_mercator(&lng_deg, &lat_deg, &dest->pos);
			
			text=buffer+pos;
			dest->text=strdup(text);
			item2=NULL;
			menu3=menu2;
			while ((tok=strtok(text,"/"))) {
				list=NULL;
				if (item2) {
					menu3=gtk_menu_new();
					gtk_menu_item_set_submenu(GTK_MENU_ITEM(item2), menu3);
				}
				list=gtk_container_get_children(GTK_CONTAINER(menu3));
				while (list) {
					item2=GTK_WIDGET(list->data);
					gtk_label_get(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item2))),&label);
					if (!strcmp(label, tok)) {
						menu3=gtk_menu_item_get_submenu(GTK_MENU_ITEM(item2));
						break;
					}
					list=list->next;
				}
				item2=NULL;
				if (! list) {
					utf8=g_locale_to_utf8(tok,-1,NULL,NULL,NULL);
					item2=gtk_menu_item_new_with_label(utf8);
					gtk_menu_append (GTK_MENU(menu3), item2); 
					g_free(utf8);
				}
				text=NULL;
			}
			gtk_signal_connect(GTK_OBJECT(item2), "activate",
				GTK_SIGNAL_FUNC (menu_destination_selected), dest);
		}
	}
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu2);

	item=gtk_menu_item_new();
	clock=gtk_label_new(NULL);
	gtk_menu_item_right_justify(GTK_MENU_ITEM(item));
	gtk_container_add(GTK_CONTAINER(item), clock);
	gtk_menu_bar_append(GTK_MENU_BAR(menu), item);
	menu_clock_update(clock);
	
	*widget=menu;
	return this;
}
static void
sensor_enabled(IsManager *manager,
               IsSensor *sensor,
               gint position,
               IsIndicator *self)
{
  IsIndicatorPrivate *priv = self->priv;

  /* make sure we haven't seen this sensor before - if sensor has a
   * menu-item then ignore it */
  if (!g_object_get_data(G_OBJECT(sensor), "menu-item"))
  {
    GtkMenu *menu;
    GtkWidget *menu_item;

    is_debug("indicator", "Creating menu item for newly enabled sensor %s",
             is_sensor_get_path(sensor));

    g_signal_connect(sensor, "notify::value",
                     G_CALLBACK(sensor_notify),
                     self);
    g_signal_connect(sensor, "notify::label",
                     G_CALLBACK(sensor_notify),
                     self);
    g_signal_connect(sensor, "notify::alarmed",
                     G_CALLBACK(sensor_notify),
                     self);
    g_signal_connect(sensor, "notify::low-value",
                     G_CALLBACK(sensor_notify),
                     self);
    g_signal_connect(sensor, "notify::high-value",
                     G_CALLBACK(sensor_notify),
                     self);
    /* add a menu entry for this sensor */
    menu = is_indicator_get_menu(self);
    menu_item = gtk_check_menu_item_new();
    gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(menu_item),
                                          TRUE);
    g_object_set_data(G_OBJECT(sensor), "menu-item", menu_item);
    g_object_set_data(G_OBJECT(menu_item), "sensor", sensor);

    priv->menu_items = g_slist_insert(priv->menu_items, menu_item,
                                      position);
    /* if we haven't seen our primary sensor yet or if this is the
     * primary sensor, display this as primary anyway */
    if (!priv->primary ||
        g_strcmp0(is_sensor_get_path(sensor),
                  priv->primary_sensor_path) == 0)
    {
      is_debug("indicator", "Using sensor with path %s as primary",
               is_sensor_get_path(sensor));
      if (priv->primary)
      {
        GtkCheckMenuItem *item;
        /* uncheck menu item if exists for this
         * existing primary sensor */
        item = (GtkCheckMenuItem *)(g_object_get_data(G_OBJECT(priv->primary),
                                    "menu-item"));
        if (item)
        {
          is_debug("indicator", "Unchecking current primary sensor item");
          gtk_check_menu_item_set_active(item, FALSE);
        }
        g_object_unref(priv->primary);
      }
      priv->primary = g_object_ref(sensor);
      is_debug("indicator", "Checking new primary sensor item");
      gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item),
                                     TRUE);
      update_sensor_menu_item_label(self, sensor,
                                    GTK_MENU_ITEM(menu_item));
    }
    /* connect to toggled signal now - if we connect to it earlier
     * we may interpret the above menu_item_set_active as a user
     * initiated setting of the primary sensor rather than us just
     * picking the first available sensor */
    g_signal_connect(menu_item, "toggled",
                     G_CALLBACK(sensor_menu_item_toggled),
                     self);
    gtk_widget_show_all(menu_item);

    update_sensor_menu_item_label(self, sensor, GTK_MENU_ITEM(menu_item));
    gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menu_item, position);
  }
  else
  {
    is_debug("indicator", "Newly enabled sensor %s already has a menu-item, ignoring...",
             is_sensor_get_path(sensor));
  }
}
Exemple #27
0
void
add_mainmenu_actions (GtkWidget *mainwin)
{
    DB_plugin_t **plugins = deadbeef->plug_get_list();
    int i;

    for (i = 0; plugins[i]; i++)
    {
        if (!plugins[i]->get_actions)
            continue;

        DB_plugin_action_t *actions = plugins[i]->get_actions (NULL);
        DB_plugin_action_t *action;

        for (action = actions; action; action = action->next)
        {
            char *tmp = NULL;
            if (0 == (action->flags & DB_ACTION_COMMON))
                continue;

            // 1st check if we have slashes
            const char *slash = action->title;
            while (NULL != (slash = strchr (slash, '/'))) {
                if (slash && slash > action->title && *(slash-1) == '\\') {
                    slash++;
                    continue;
                }
                break;
            }
            if (!slash) {
                continue;
            }

            char *ptr = tmp = strdup (action->title);

            char *prev_title = NULL;

            GtkWidget *current = mainwin;
            GtkWidget *previous;

            while (1)
            {
                // find unescaped forward slash
                char *slash = strchr (ptr, '/');
                if (slash && slash > ptr && *(slash-1) == '\\') {
                    ptr = slash + 1;
                    continue;
                }

                if (!slash)
                {
                    GtkWidget *actionitem;
                    actionitem = gtk_image_menu_item_new_with_mnemonic (_(ptr));
                    gtk_widget_show (actionitem);

                    /* Here we have special cases for different submenus */
                    if (0 == strcmp ("File", prev_title))
                        gtk_menu_shell_insert (GTK_MENU_SHELL (current), actionitem, 5);
                    else if (0 == strcmp ("Edit", prev_title))
                        gtk_menu_shell_insert (GTK_MENU_SHELL (current), actionitem, 7);
                    else
                        gtk_container_add (GTK_CONTAINER (current), actionitem);

                    g_signal_connect ((gpointer) actionitem, "activate",
                        G_CALLBACK (on_actionitem_activate),
                        action);
                    break;
                }
                *slash = 0;
                char menuname [1024];

                snprintf (menuname, sizeof (menuname), "%s_menu", ptr);

                previous = current;
                current = lookup_widget (current, menuname);
                if (!current)
                {
                    GtkWidget *newitem;

                    newitem = gtk_menu_item_new_with_mnemonic (ptr);
                    gtk_widget_show (newitem);

                    //If we add new submenu in main bar, add it before 'Help'
                    if (NULL == prev_title)
                        gtk_menu_shell_insert (GTK_MENU_SHELL (previous), newitem, 4);
                    else
                        gtk_container_add (GTK_CONTAINER (previous), newitem);

                    current = gtk_menu_new ();
                    gtk_menu_item_set_submenu (GTK_MENU_ITEM (newitem), current);
                }
                prev_title = ptr;
                ptr = slash + 1;
            }
            if (tmp) {
                free (tmp);
            }
        }
    }
}
Exemple #28
0
void pMenu::setText(const string &text) {
  gtk_menu_item_set_label(GTK_MENU_ITEM(widget), mnemonic(text));
}
Exemple #29
0
static void *gtk_thread(void *arg)
{
	struct gtk_mod *mod = arg;
	GtkMenuShell *app_menu;
	GtkWidget *item;
	GError *err = NULL;
	struct le *le;

	gdk_threads_init();
	gtk_init(0, NULL);

	g_set_application_name("baresip");
	mod->app = g_application_new ("com.creytiv.baresip",
			G_APPLICATION_FLAGS_NONE);

	g_application_register (G_APPLICATION (mod->app), NULL, &err);
	if (err != NULL) {
		warning ("Unable to register GApplication: %s",
				err->message);
		g_error_free (err);
		err = NULL;
	}

#ifdef USE_LIBNOTIFY
	notify_init("baresip");
#endif

	mod->status_icon = gtk_status_icon_new_from_icon_name("call-start");
	gtk_status_icon_set_tooltip_text (mod->status_icon, "baresip");

	g_signal_connect(G_OBJECT(mod->status_icon),
			"button_press_event",
			G_CALLBACK(status_icon_on_button_press), mod);
	gtk_status_icon_set_visible(mod->status_icon, TRUE);

	mod->contacts_inited = false;
	mod->dial_dialog = NULL;
	mod->call_windows = NULL;
	mod->incoming_call_menus = NULL;

	/* App menu */
	mod->app_menu = gtk_menu_new();
	app_menu = GTK_MENU_SHELL(mod->app_menu);

	/* Account submenu */
	mod->accounts_menu = gtk_menu_new();
	mod->accounts_menu_group = NULL;
	item = gtk_menu_item_new_with_mnemonic("_Account");
	gtk_menu_shell_append(app_menu, item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
			mod->accounts_menu);

	/* Add accounts to submenu */
	for (le = list_head(uag_list()); le; le = le->next) {
		struct ua *ua = le->data;
		accounts_menu_add_item(mod, ua);
	}

	/* Status submenu */
	mod->status_menu = gtk_menu_new();
	item = gtk_menu_item_new_with_mnemonic("_Status");
	gtk_menu_shell_append(GTK_MENU_SHELL(app_menu), item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), mod->status_menu);

	/* Open */
	item = gtk_radio_menu_item_new_with_label(NULL, "Open");
	g_object_set_data(G_OBJECT(item), "presence",
			GINT_TO_POINTER(PRESENCE_OPEN));
	g_signal_connect(item, "activate",
			G_CALLBACK(menu_on_presence_set), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(mod->status_menu), item);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE);

	/* Closed */
	item = gtk_radio_menu_item_new_with_label_from_widget(
			GTK_RADIO_MENU_ITEM(item), "Closed");
	g_object_set_data(G_OBJECT(item), "presence",
			GINT_TO_POINTER(PRESENCE_CLOSED));
	g_signal_connect(item, "activate",
			G_CALLBACK(menu_on_presence_set), mod);
	gtk_menu_shell_append(GTK_MENU_SHELL(mod->status_menu), item);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* Dial */
	item = gtk_menu_item_new_with_mnemonic("_Dial...");
	gtk_menu_shell_append(app_menu, item);
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_dial), mod);

	/* Dial contact */
	mod->contacts_menu = gtk_menu_new();
	item = gtk_menu_item_new_with_mnemonic("Dial _contact");
	gtk_menu_shell_append(app_menu, item);
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
			mod->contacts_menu);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* About */
	item = gtk_menu_item_new_with_mnemonic("A_bout");
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_about), mod);
	gtk_menu_shell_append(app_menu, item);

	gtk_menu_shell_append(app_menu, gtk_separator_menu_item_new());

	/* Quit */
	item = gtk_menu_item_new_with_mnemonic("_Quit");
	g_signal_connect(G_OBJECT(item), "activate",
			G_CALLBACK(menu_on_quit), mod);
	gtk_menu_shell_append(app_menu, item);

	g_action_map_add_action_entries(G_ACTION_MAP(mod->app),
			app_entries, G_N_ELEMENTS(app_entries), mod);

	info("gtk_menu starting\n");

	uag_event_register( ua_event_handler, mod );
	mod->run = true;
	gtk_main();
	mod->run = false;
	uag_event_unregister(ua_event_handler);

	if (mod->dial_dialog) {
		mem_deref(mod->dial_dialog);
		mod->dial_dialog = NULL;
	}

	return NULL;
}
Exemple #30
0
WAttGtk::WAttGtk( 
	GtkWidget      	*wa_parent_wid,
	void 		*wa_parent_ctx, 
	ldh_tSesContext wa_ldhses, 
	pwr_sAttrRef 	wa_aref,
	int 		wa_editmode,
	int 		wa_advanced_user,
	int		wa_display_objectname) :
  WAtt(wa_parent_ctx,wa_ldhses,wa_aref,wa_editmode,wa_advanced_user,
       wa_display_objectname), parent_wid(wa_parent_wid)
{
  int sts;
  int size;
  char *namep;

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

  toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW, 
					 "default-height", 570,
					 "default-width", 410,
					 "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);

  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_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_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
  g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), 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("_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( "_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( "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);

  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);

  GtkWidget *functions = gtk_menu_item_new_with_mnemonic("_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("_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();

  if ( ((WUtility *)parent_ctx)->utype == wb_eUtility_WNav)
    parent_ctx = ((WNav *)parent_ctx)->parent_ctx;
  utility = ((WUtility *)parent_ctx)->utype;
  
  wattnav = new WAttNavGtk( (void *)this, wattnav_eType_Object, pane, "Plant",
			      ldhses, aref, wa_editmode, wa_advanced_user,
			      wa_display_objectname, utility, &brow_widget, &sts);
  ((WAttNav *)wattnav)->message_cb = &WAtt::message_cb;
  ((WAttNav *)wattnav)->change_value_cb = &WAtt::change_value_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_entry->set_hide_on_esc(true);
  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);
  g_signal_connect( cmd_input, "hide",
		    G_CALLBACK(hide_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);

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