Ejemplo n.º 1
0
static void
_brio_application_set_app_menu (GApplication *app)
{
  GMenu *app_menu = g_menu_new ();
  GSimpleAction *about;
  GSimpleAction *quit;

  about = g_simple_action_new ("about", NULL);
  g_signal_connect (about,
                    "activate",
                    G_CALLBACK (_brio_application_show_about),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about));
  g_menu_append (app_menu, _("About"), "app.about");

  quit = g_simple_action_new ("quit", NULL);
  g_signal_connect (quit,
                    "activate",
                    G_CALLBACK (_brio_application_quit),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit));
  g_menu_append (app_menu, _("Quit"), "app.quit");

  gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu));
}
Ejemplo n.º 2
0
static void
application_startup_cb (GApplication       *application,
                        GnomeControlCenter *shell)
{
  GMenu *menu, *section;
  GAction *action;

  action = G_ACTION (g_simple_action_new ("help", NULL));
  g_action_map_add_action (G_ACTION_MAP (application), action);
  g_signal_connect (action, "activate", G_CALLBACK (help_activated), shell);

  action = G_ACTION (g_simple_action_new ("quit", NULL));
  g_action_map_add_action (G_ACTION_MAP (application), action);
  g_signal_connect (action, "activate", G_CALLBACK (quit_activated), shell);

  menu = g_menu_new ();

  section = g_menu_new ();
  g_menu_append (section, _("Help"), "app.help");
  g_menu_append (section, _("Quit"), "app.quit");

  g_menu_append_section (menu, NULL, G_MENU_MODEL (section));

  gtk_application_set_app_menu (GTK_APPLICATION (application),
                                G_MENU_MODEL (menu));

  gtk_application_add_accelerator (GTK_APPLICATION (application),
                                   "F1", "app.help", NULL);

  /* nothing else to do here, we don't want to show a window before
   * we've looked at the commandline
   */
}
Ejemplo n.º 3
0
static GSimpleActionGroup *
create_action_group(ReaderWindowPrivate *priv)
{
	GSimpleActionGroup *actions = g_simple_action_group_new();

	gboolean side_pane = cainteoir_settings_get_boolean(priv->settings, "index", "visible", TRUE);

	priv->index_pane_action = g_simple_action_new_stateful("side-pane", nullptr, g_variant_new_boolean(side_pane));
	g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->index_pane_action));
	g_signal_connect(priv->index_pane_action, "activate", G_CALLBACK(on_index_pane_toggle_action), priv);

	priv->open_action = g_simple_action_new("open", nullptr);
	g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->open_action));
	g_signal_connect(priv->open_action, "activate", G_CALLBACK(on_open_file_action), priv);

	priv->play_stop_action = g_simple_action_new("play-stop", nullptr);
	g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->play_stop_action));
	g_signal_connect(priv->play_stop_action, "activate", G_CALLBACK(on_play_stop_action), priv);

	priv->record_action = g_simple_action_new("record", nullptr);
	g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->record_action));
	g_signal_connect(priv->record_action, "activate", G_CALLBACK(on_record_action), priv);

	return actions;
}
Ejemplo n.º 4
0
static void
shell_add_actions (GApplication *application)
{
	GActionMap *action_map;
	GSimpleAction *action;

	action_map = G_ACTION_MAP (application);

	/* Add actions that remote instances can invoke. */

	action = g_simple_action_new ("new-window", G_VARIANT_TYPE_STRING);
	g_signal_connect (
		action, "activate",
		G_CALLBACK (shell_action_new_window_cb), application);
	g_action_map_add_action (action_map, G_ACTION (action));
	g_object_unref (action);

	action = g_simple_action_new (
		"handle-uris", G_VARIANT_TYPE_STRING_ARRAY);
	g_signal_connect (
		action, "activate",
		G_CALLBACK (shell_action_handle_uris_cb), application);
	g_action_map_add_action (action_map, G_ACTION (action));
	g_object_unref (action);

	action = g_simple_action_new ("quit", NULL);
	g_signal_connect (
		action, "activate",
		G_CALLBACK (shell_action_quit_cb), application);
	g_action_map_add_action (action_map, G_ACTION (action));
	g_object_unref (action);
}
Ejemplo n.º 5
0
static void
impl_activate (PeasActivatable *plugin)
{
	TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin);
	TotemDiscRecorderPluginPrivate *priv = pi->priv;
	GMenu *menu;
	char *path;

	/* make sure brasero is in the path */
	path = g_find_program_in_path ("brasero");
	if (!path)
		return;
	g_free (path);

	priv->totem = g_object_get_data (G_OBJECT (plugin), "object");

	g_signal_connect (priv->totem,
			  "file-opened",
			  G_CALLBACK (totem_disc_recorder_file_opened),
			  plugin);
	g_signal_connect (priv->totem,
			  "file-closed",
			  G_CALLBACK (totem_disc_recorder_file_closed),
			  plugin);

	/* Create the actions */
	priv->dvd_action = g_simple_action_new ("media-optical-video-new", NULL);
	g_signal_connect (G_OBJECT (priv->dvd_action), "activate",
			  G_CALLBACK (totem_disc_recorder_plugin_burn), plugin);
	g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->dvd_action));

	priv->copy_action = g_simple_action_new ("media-optical-copy", NULL);
	g_signal_connect (G_OBJECT (priv->copy_action), "activate",
			  G_CALLBACK (totem_disc_recorder_plugin_copy), plugin);
	g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_action));

	priv->copy_vcd_action = g_simple_action_new ("media-optical-copy-vcd", NULL);
	g_signal_connect (G_OBJECT (priv->copy_vcd_action), "activate",
			  G_CALLBACK (totem_disc_recorder_plugin_copy), plugin);
	g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_vcd_action));

	/* Install the menu */
	menu = totem_object_get_menu_section (priv->totem, "burn-placeholder");
	menu_append_hidden (G_MENU (menu), _("_Create Video Disc…"), "app.media-optical-video-new");
	menu_append_hidden (G_MENU (menu), _("Copy Vide_o DVD…"), "app.media-optical-copy");
	menu_append_hidden (G_MENU (menu), _("Copy (S)VCD…"), "app.media-optical-copy-vcd");

	if (!totem_object_is_paused (priv->totem) && !totem_object_is_playing (priv->totem)) {
		set_menu_items_state (pi, FALSE, FALSE, FALSE);
	} else {
		char *mrl;

		mrl = totem_object_get_current_mrl (priv->totem);
		totem_disc_recorder_file_opened (priv->totem, mrl, pi);
		g_free (mrl);
	}
}
static void
cc_application_startup (GApplication *application)
{
  CcApplication *self = CC_APPLICATION (application);
  GMenu *menu;
  GMenu *section;
  GSimpleAction *action;

  G_APPLICATION_CLASS (cc_application_parent_class)->startup (application);

#ifdef HAVE_CHEESE
  if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
    {
      g_critical ("Unable to initialize Clutter");
      return;
    }
#endif /* HAVE_CHEESE */

  /* register a symbolic icon size for use in sidebar lists */
  gtk_icon_size_register ("cc-sidebar-list", 24, 24);

  action = g_simple_action_new ("help", NULL);
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (help_activated), self);
  g_object_unref (action);

  action = g_simple_action_new ("quit", NULL);
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (cc_application_quit), self);
  g_object_unref (action);

  /* Launch panel by id. The parameter is a (panel_id, array_of_panel_parameters)
   * tuple. The GVariant-containing array usually is just the same array of
   * strings that would be generated by passing panel-specific arguments on
   * the command line. */
  action = g_simple_action_new ("launch-panel", G_VARIANT_TYPE ("(sav)"));
  g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));
  g_signal_connect (action, "activate", G_CALLBACK (launch_panel_activated), self);
  g_object_unref (action);

  menu = g_menu_new ();

  section = g_menu_new ();
  g_menu_append (section, _("Help"), "app.help");
  g_menu_append (section, _("Quit"), "app.quit");

  g_menu_append_section (menu, NULL, G_MENU_MODEL (section));

  gtk_application_set_app_menu (GTK_APPLICATION (application),
                                G_MENU_MODEL (menu));

  gtk_application_add_accelerator (GTK_APPLICATION (application),
                                   "F1", "app.help", NULL);

  self->priv->window = cc_window_new (GTK_APPLICATION (application));
}
Ejemplo n.º 7
0
static void
toggle_speed (GtkToggleButton *button, gpointer data)
{
  GMenuModel *model;
  GActionGroup *group;
  GSimpleAction *action;
  gboolean adding;
  GMenuModel *m;
  GMenu *submenu;
  GtkTreeView *tv = data;
  GtkTreeModel *store;

  model = g_object_get_data (G_OBJECT (button), "model");
  group = g_object_get_data (G_OBJECT (button), "group");

  store = gtk_tree_view_get_model (tv);

  adding = gtk_toggle_button_get_active (button);

  m = g_menu_model_get_item_link (model, 1, G_MENU_LINK_SECTION);
  if (adding)
    {
      action = g_simple_action_new ("faster", NULL);
      g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
      g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL);
      g_object_unref (action);

      action = g_simple_action_new ("slower", NULL);
      g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action));
      g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL);
      g_object_unref (action);

      action_list_add (store, "faster");
      action_list_add (store, "slower");

      submenu = g_menu_new ();
      g_menu_append (submenu, "Faster", "faster");
      g_menu_append (submenu, "Slower", "slower");
      g_menu_append_submenu (G_MENU (m), "Speed", G_MENU_MODEL (submenu));
    }
  else
    {
      g_action_map_remove_action (G_ACTION_MAP (group), "faster");
      g_action_map_remove_action (G_ACTION_MAP (group), "slower");

      action_list_remove (store, "faster");
      action_list_remove (store, "slower");

      g_menu_remove (G_MENU (m), g_menu_model_get_n_items (m) - 1);
    }
}
Ejemplo n.º 8
0
static void 
gcal_application_set_app_menu (GApplication *app)
{
  GcalApplicationPrivate *priv;

  GMenu *app_menu;
  GMenu *view_as;
  GSimpleAction *about;
  GSimpleAction *quit;

  g_return_if_fail (GCAL_IS_APPLICATION (app));
  priv = GCAL_APPLICATION (app)->priv;

  app_menu = g_menu_new ();

  priv->view = g_simple_action_new_stateful (
      "view",
      G_VARIANT_TYPE_STRING,
      g_settings_get_value (priv->settings, "active-view"));

  g_signal_connect (priv->view,
                    "activate",
                    G_CALLBACK (gcal_application_change_view),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (priv->view));

  view_as = g_menu_new ();
  g_menu_append (view_as, _("Weeks"), "app.view::week");
  g_menu_append (view_as, _("Months"), "app.view::month");

  g_menu_append_section (app_menu, _("View as"), G_MENU_MODEL (view_as));

  about = g_simple_action_new ("about", NULL);
  g_signal_connect (about,
                    "activate",
                    G_CALLBACK (gcal_application_show_about),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about));
  g_menu_append (app_menu, _("About"), "app.about");

  quit = g_simple_action_new ("quit", NULL);
  g_signal_connect (quit,
                    "activate",
                    G_CALLBACK (gcal_application_quit),
                    app);
  g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit));
  g_menu_append (app_menu, _("Quit"), "app.quit");

  gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu));
}
Ejemplo n.º 9
0
static void
startup (GApplication *app,
         gpointer      user_data)
{
  GSimpleAction *new_action;
  GSimpleAction *quit_action;

  new_action = g_simple_action_new ("new", NULL);
  g_signal_connect (new_action, "activate", G_CALLBACK (new_callback), app);
  g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (new_action));

  quit_action = g_simple_action_new ("quit", NULL);
  g_signal_connect (quit_action, "activate", G_CALLBACK (quit_callback), app);
  g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action));
}
Ejemplo n.º 10
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GtkWidget *window;

  GSimpleAction *about_action;

  /* Create a window with a title and a default size */
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "AboutDialog Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  /* Create a new simple action, giving it a NULL parameter type. It will 
   * always be NULL for actions invoked from a menu. (e.g clicking on an "ok" 
   * or "cancel" button)
   */
  about_action = g_simple_action_new ("about", NULL); 

  /* Connect the "activate" signal to the appropriate callback function. 
   * It will indicate that the action was just activated.
   */
  g_signal_connect (about_action, "activate", G_CALLBACK (about_cb), 
                    GTK_WINDOW (window));

  /* Adds the about_action to the overall action map. An Action map is an 
   * interface that contains a number of named GAction instances 
   * (such as about_action) 
   */
  g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action));

  gtk_widget_show_all (window);
}
Ejemplo n.º 11
0
/* Startup function for the menu we are creating in this sample */
static void
startup (GApplication *app,
         gpointer      user_data)
{
  GMenu *menu;
  GSimpleAction *quit_action;

  /* Initialize the GMenu, and add a menu item with label "About" and action 
   * "win.about". Also add another menu item with label "Quit" and action 
   * "app.quit" 
   */
  menu = g_menu_new ();
  g_menu_append (menu, "About", "win.about");
  g_menu_append (menu, "Quit", "app.quit");

  /* Create a new simple action for the application. (In this case it is the 
   * "quit" action.
   */
  quit_action = g_simple_action_new ("quit", NULL);

  /* Ensure that the menu we have just created is set for the overall application */
  gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (menu));

  g_signal_connect (quit_action, 
                    "activate", 
                    G_CALLBACK (quit_cb), 
                    app);

  g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action));

}
Ejemplo n.º 12
0
/* Object initialization
 * Create private structure and set up default values
 */
static void xfdashboard_application_init(XfdashboardApplication *self)
{
	XfdashboardApplicationPrivate	*priv;
	GSimpleAction					*action;

	priv=self->priv=XFDASHBOARD_APPLICATION_GET_PRIVATE(self);

	/* Set default values */
	priv->isDaemon=FALSE;
	priv->isSuspended=FALSE;
	priv->themeName=NULL;
	priv->inited=FALSE;
	priv->xfconfChannel=NULL;
	priv->viewManager=NULL;
	priv->searchManager=NULL;
	priv->focusManager=NULL;
	priv->theme=NULL;
	priv->xfconfThemeChangedSignalID=0L;
	priv->isQuitting=FALSE;
	priv->sessionManagementClient=NULL;

	/* Add callable DBUS actions for this application */
	action=g_simple_action_new("Quit", NULL);
	g_signal_connect(action, "activate", G_CALLBACK(xfdashboard_application_quit_forced), NULL);
	g_action_map_add_action(G_ACTION_MAP(self), G_ACTION(action));
	g_object_unref(action);
}
Ejemplo n.º 13
0
Archivo: paint.c Proyecto: sam-m888/gtk
static void
drawing_area_hierarchy_changed (GtkWidget *widget,
                                GtkWidget *previous_toplevel)
{
  DrawingArea *area = (DrawingArea *) widget;
  GSimpleActionGroup *action_group;
  GSimpleAction *action;
  GtkWidget *toplevel;
  gint i;

  if (previous_toplevel && area->pad_controller)
    {
      gtk_widget_remove_controller (previous_toplevel,
                                    GTK_EVENT_CONTROLLER (area->pad_controller));
      area->pad_controller = NULL;
    }

  toplevel = gtk_widget_get_toplevel (GTK_WIDGET (area));
  if (!GTK_IS_WINDOW (toplevel))
    return;

  action_group = g_simple_action_group_new ();
  area->pad_controller = gtk_pad_controller_new (G_ACTION_GROUP (action_group),
                                                 NULL);

  for (i = 0; i < G_N_ELEMENTS (pad_actions); i++)
    {
      if (pad_actions[i].type == GTK_PAD_ACTION_BUTTON)
        {
          action = g_simple_action_new (pad_actions[i].action_name, NULL);
          g_object_set_data (G_OBJECT (action), "color",
                             (gpointer) pad_colors[i]);
          g_signal_connect (action, "activate",
                            G_CALLBACK (on_pad_button_activate), area);
        }
      else
        {
          action = g_simple_action_new_stateful (pad_actions[i].action_name,
                                                 G_VARIANT_TYPE_DOUBLE, NULL);
          g_signal_connect (action, "activate",
                            G_CALLBACK (on_pad_knob_change), area);
        }

      g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (action));
      g_object_unref (action);
    }

  gtk_pad_controller_set_action_entries (area->pad_controller, pad_actions,
                                         G_N_ELEMENTS (pad_actions));

  gtk_widget_add_controller (toplevel,
                             GTK_EVENT_CONTROLLER (area->pad_controller));
}
Ejemplo n.º 14
0
static void
impl_activate (EogWindowActivatable *activatable)
{
	const gchar * const accel_keys[] = { "W", NULL };
	EogFitToWidthPlugin *plugin = EOG_FIT_TO_WIDTH_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;
	GAction *ref_action;

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_FIT_TO_WIDTH_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (fit_to_width_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));

	/* Bind to the zoom-normal action's enabled property to only enable
	 * fit-to-width zooming if zooming is generally enabled */
	ref_action = g_action_map_lookup_action (G_ACTION_MAP (plugin->window),
						 "zoom-normal");
	if (ref_action)
		g_object_bind_property (ref_action, "enabled",
					action, "enabled",
					G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
	g_object_unref (action);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Fit to width"),
		       "win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_FIT_TO_WIDTH_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "zoom-fit-best-symbolic");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

	/* Define accelerator keys */
	gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP),
					       "win." EOG_FIT_TO_WIDTH_PLUGIN_ACTION,
					       accel_keys);
}
Ejemplo n.º 15
0
static void
eog_reload_plugin_activate (EogWindowActivatable *activatable)
{
	const gchar * const accel_keys[] = { "R", NULL };
	EogReloadPlugin *plugin = EOG_RELOAD_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;

	eog_debug (DEBUG_PLUGINS);

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_RELOAD_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (reload_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));
	g_object_unref (action);

	g_signal_connect (G_OBJECT (eog_window_get_thumb_view (plugin->window)),
			  "selection-changed",
			  G_CALLBACK (_selection_changed_cb),
			  plugin);
	eog_reload_plugin_update_action_state (plugin);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Reload Image"),
		       "win." EOG_RELOAD_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_RELOAD_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "view-refresh-symbolic");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

	/* Define accelerator keys */
	gtk_application_set_accels_for_action (GTK_APPLICATION (EOG_APP),
					       "win." EOG_RELOAD_PLUGIN_ACTION,
					       accel_keys);
}
Ejemplo n.º 16
0
void main_window_menu(GtkApplicationWindow* window, main_window* data){
    GSimpleAction* action;

    action = g_simple_action_new("new", NULL);
    g_signal_connect(action, "activate", G_CALLBACK(new_handler), data);
    g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));

    action = g_simple_action_new("open", NULL);
    g_signal_connect(action, "activate", G_CALLBACK(open_handler), data);
    g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));

    action = g_simple_action_new("quit", NULL);
    g_signal_connect_swapped(action, "activate",
        G_CALLBACK(gtk_window_close), window);
    g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));

    action = g_simple_action_new("zoomin", NULL);
    g_signal_connect(action, "activate", G_CALLBACK(zoom_in), data);
    g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));

    action = g_simple_action_new("zoomout", NULL);
    g_signal_connect(action, "activate", G_CALLBACK(zoom_out), data);
    g_action_map_add_action(G_ACTION_MAP(window), G_ACTION(action));
}
Ejemplo n.º 17
0
Archivo: start.c Proyecto: y20k/ezeedo
/**
 * Creates window menu
 */
GtkWidget
*create_windowmenu (ezeedo_wrapper_structure *ezeedo)
{
    // define widgets
    GtkWidget *windowmenu_button;
    GtkWidget *win;
    GMenu     *windowmenu;

    win = ezeedo->window;

    // define actions
    GSimpleAction *toggle_action;

    // create gear menu
    windowmenu = g_menu_new ();
    g_menu_append (windowmenu,
                   "Toggle sidebar",
                   "win.toggle_sidebar");

    // create actions
    toggle_action = g_simple_action_new ("toggle_sidebar",
                                         NULL);
    g_signal_connect (toggle_action, "activate",
                      G_CALLBACK(toggle_sidebar), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(win),
                             G_ACTION(toggle_action));

    // activate ctrl-h
    const gchar* toggle_accels[2] = { "<Ctrl>H", NULL };
    gtk_application_set_accels_for_action (GTK_APPLICATION(ezeedo->application),
                                           "win.toggle_sidebar",
                                            toggle_accels);

    // create window menu 
    windowmenu_button  = gtk_menu_button_new ();
    gtk_menu_button_set_direction (GTK_MENU_BUTTON(windowmenu_button),
                                   GTK_ARROW_NONE);

    // attach window menu to button
    gtk_menu_button_set_use_popover (GTK_MENU_BUTTON(windowmenu_button),
                                     true);
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON(windowmenu_button),
                                    G_MENU_MODEL(windowmenu)); 

    // return button with window menu
    return (windowmenu_button);
}
Ejemplo n.º 18
0
static void
nemo_application_init (NemoApplication *application)
{
	GSimpleAction *action;

	application->priv =
		G_TYPE_INSTANCE_GET_PRIVATE (application, NEMO_TYPE_APPLICATION,
					     NemoApplicationPriv);

	action = g_simple_action_new ("quit", NULL);

        g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action));

	g_signal_connect_swapped (action, "activate",
				  G_CALLBACK (nemo_application_quit), application);

	g_object_unref (action);
}
Ejemplo n.º 19
0
static void
enable_plugin (const gchar *name)
{
  GMenuModel *plugin_menu;
  GAction *action;

  g_print ("Enabling '%s' plugin\n", name);

  action = (GAction *)g_simple_action_new (name, NULL);
  g_signal_connect (action, "activate", G_CALLBACK (plugin_action), (gpointer)name);
  g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), action);
  g_print ("Actions of '%s' plugin added\n", name);
  g_object_unref (action);

  plugin_menu = find_plugin_menu ();
  if (plugin_menu)
    {
      GMenu *section;
      GMenuItem *item;
      gchar *label;
      gchar *action_name;

      section = g_menu_new ();
      label = g_strdup_printf ("Turn text %s", name);
      action_name = g_strconcat ("app.", name, NULL);
      g_menu_insert (section, 0, label, action_name);
      g_free (label);
      g_free (action_name);
      item = g_menu_item_new_section (NULL, (GMenuModel*)section);
      g_menu_item_set_attribute (item, "id", "s", name);
      g_menu_append_item (G_MENU (plugin_menu), item);
      g_object_unref (item);
      g_object_unref (section);
      g_print ("Menus of '%s' plugin added\n", name);
    }
  else
    g_warning ("Plugin menu not found\n");

  if (g_strcmp0 (name, "red") == 0)
    is_red_plugin_enabled = TRUE;
  else
    is_black_plugin_enabled = TRUE;
}
Ejemplo n.º 20
0
static void
impl_activate (EogWindowActivatable *activatable)
{
	EogPostrPlugin *plugin = EOG_POSTR_PLUGIN (activatable);
	GMenu *model, *menu;
	GMenuItem *item;
	GSimpleAction *action;

	eog_debug (DEBUG_PLUGINS);

	g_return_if_fail (plugin->window != NULL);

	model= eog_window_get_gear_menu_section (plugin->window,
						 "plugins-section");

	g_return_if_fail (G_IS_MENU (model));

	/* Setup and inject action */
	action = g_simple_action_new (EOG_POSTR_PLUGIN_ACTION, NULL);
	g_signal_connect(action, "activate",
			 G_CALLBACK (postr_cb), plugin->window);
	g_action_map_add_action (G_ACTION_MAP (plugin->window),
				 G_ACTION (action));
	g_object_unref (action);

	/* Append entry to the window's gear menu */
	menu = g_menu_new ();
	g_menu_append (menu, _("Upload to Flickr"),
		       "win." EOG_POSTR_PLUGIN_ACTION);

	item = g_menu_item_new_section (NULL, G_MENU_MODEL (menu));
	g_menu_item_set_attribute (item, "id",
				   "s", EOG_POSTR_PLUGIN_MENU_ID);
	g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON,
				   "s", "postr");
	g_menu_append_item (model, item);
	g_object_unref (item);

	g_object_unref (menu);

}
Ejemplo n.º 21
0
static void
impl_activate (PeasActivatable *plugin)
{
	GtkWindow *window;
	TotemSkiptoPlugin *pi = TOTEM_SKIPTO_PLUGIN (plugin);
	TotemSkiptoPluginPrivate *priv = pi->priv;
	GMenu *menu;
	GMenuItem *item;

	priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
	priv->handler_id_stream_length = g_signal_connect (G_OBJECT (priv->totem),
				"notify::stream-length",
				G_CALLBACK (property_notify_cb),
				pi);
	priv->handler_id_seekable = g_signal_connect (G_OBJECT (priv->totem),
				"notify::seekable",
				G_CALLBACK (property_notify_cb),
				pi);

	/* Key press handler */
	window = totem_object_get_main_window (priv->totem);
	priv->handler_id_key_press = g_signal_connect (G_OBJECT(window),
				"key-press-event",
				G_CALLBACK (on_window_key_press_event),
				pi);
	g_object_unref (window);

	/* Install the menu */
	priv->action = g_simple_action_new ("skip-to", NULL);
	g_signal_connect (G_OBJECT (priv->action), "activate",
			  G_CALLBACK (skip_to_action_callback), plugin);
	g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->action));

	menu = totem_object_get_menu_section (priv->totem, "skipto-placeholder");
	item = g_menu_item_new (_("_Skip To…"), "app.skip-to");
	g_menu_item_set_attribute (item, "accel", "s", "<Ctrl>K");
	g_menu_append_item (G_MENU (menu), item);

	totem_skipto_update_from_state (priv->totem, pi);
}
static void
add_actions (GApplication *app)
{
  GSimpleActionGroup *actions;
  GSimpleAction *action;

  actions = g_simple_action_group_new ();

  action = g_simple_action_new ("simple-action", NULL);
  g_signal_connect (action, "activate", G_CALLBACK (activate_action), app);
  g_simple_action_group_insert (actions, G_ACTION (action));
  g_object_unref (action);

  action = g_simple_action_new_stateful ("toggle-action", NULL,
                                         g_variant_new_boolean (FALSE));
  g_signal_connect (action, "activate", G_CALLBACK (activate_toggle_action), app);
  g_simple_action_group_insert (actions, G_ACTION (action));
  g_object_unref (action);

  g_application_set_action_group (app, G_ACTION_GROUP (actions));
  g_object_unref (actions);
}
Ejemplo n.º 23
0
static void
activate (GtkApplication *app,
          gpointer        user_data)
{
  GMenu *submenu;
  GtkWidget *grid;
  GMenu *menumodel;
  GtkWidget *window;
  GtkWidget *menubutton;
  GSimpleAction *about_action;

  window = gtk_application_window_new (app);
  grid = gtk_grid_new ();

  gtk_window_set_title (GTK_WINDOW (window), "MenuButton Example");
  gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);

  menubutton = gtk_menu_button_new ();
  gtk_widget_set_size_request (menubutton, 80, 35);

  gtk_grid_attach (GTK_GRID (grid), menubutton, 0, 0, 1, 1);
  gtk_container_add (GTK_CONTAINER (window), grid);

  menumodel = g_menu_new ();
  g_menu_append (menumodel, "New", "app.new");
  g_menu_append (menumodel, "About", "win.about");

  submenu = g_menu_new ();
  g_menu_append_submenu (menumodel, "Other", G_MENU_MODEL (submenu));
  g_menu_append (submenu, "Quit", "app.quit");
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (menubutton), G_MENU_MODEL (menumodel));

  about_action = g_simple_action_new ("about", NULL);
  g_signal_connect (about_action, "activate", G_CALLBACK (about_callback),
                    GTK_WINDOW (window));
  g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action));

  gtk_widget_show_all (window);
}
Ejemplo n.º 24
0
void
Ekiga::GActorMenu::add_gio_action (Ekiga::ActionPtr a)
{
  GSimpleAction *action = NULL;

  /* Action is disabled or already present */
  if (!a->is_enabled ())
    return;

  g_action_map_remove_action (G_ACTION_MAP (g_application_get_default ()),
                              a->get_name ().c_str ());

  action = g_simple_action_new (a->get_name ().c_str (), NULL);
  g_object_set_data_full (G_OBJECT (action), "action",
                          g_strdup (a->get_name ().c_str ()),
                          (GDestroyNotify) g_free);
  g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()),
                           G_ACTION (action));
  g_signal_connect (action, "activate",
                    G_CALLBACK (action_activated),
                    (gpointer) this);
  g_object_unref (action);
}
Ejemplo n.º 25
0
void
_rb_add_display_page_actions (GActionMap *map, GObject *shell, const GActionEntry *actions, gint n_entries)
{
	int i;
	for (i = 0; i < n_entries; i++) {
		GSimpleAction *action;
		const GVariantType *parameter_type;
		DisplayPageActionData *page_action_data;

		if (g_action_map_lookup_action (map, actions[i].name) != NULL) {
			/* action was already added */
			continue;
		}

		if (actions[i].parameter_type) {
			parameter_type = G_VARIANT_TYPE (actions[i].parameter_type);
		} else {
			parameter_type = NULL;
		}

		if (actions[i].state) {
			GVariant *state;
			GError *error = NULL;
			state = g_variant_parse (NULL, actions[i].state, NULL, NULL, &error);
			if (state == NULL) {
				g_critical ("could not parse state value '%s' for action "
					    "%s: %s",
					    actions[i].state, actions[i].name, error->message);
				g_error_free (error);
				continue;
			}
			action = g_simple_action_new_stateful (actions[i].name,
							       parameter_type,
							       state);
		} else {
			action = g_simple_action_new (actions[i].name, parameter_type);
		}

		if (actions[i].activate) {
			GClosure *closure;
			page_action_data = g_slice_new0 (DisplayPageActionData);
			page_action_data->u.gaction = (DisplayPageActionActivateCallback) actions[i].activate;
			page_action_data->shell = shell;
			g_object_add_weak_pointer (shell, &page_action_data->shell);

			closure = g_cclosure_new (G_CALLBACK (display_page_action_activate_cb),
						  page_action_data,
						  (GClosureNotify) display_page_action_data_destroy);
			g_signal_connect_closure (action, "activate", closure, FALSE);
		}

		if (actions[i].change_state) {
			GClosure *closure;
			page_action_data = g_slice_new0 (DisplayPageActionData);
			page_action_data->u.gactionstate = (DisplayPageActionChangeStateCallback) actions[i].change_state;
			page_action_data->shell = shell;
			g_object_add_weak_pointer (shell, &page_action_data->shell);

			closure = g_cclosure_new (G_CALLBACK (display_page_action_change_state_cb),
						  page_action_data,
						  (GClosureNotify) display_page_action_data_destroy);
			g_signal_connect_closure (action, "change-state", closure, FALSE);
		}

		g_action_map_add_action (map, G_ACTION (action));
		g_object_unref (action);
	}
}
Ejemplo n.º 26
0
static void
photos_application_startup (GApplication *application)
{
  PhotosApplication *self = PHOTOS_APPLICATION (application);
  PhotosApplicationPrivate *priv = self->priv;
  GError *error;
  GSimpleAction *action;
  GrlRegistry *registry;
  GtkSettings *settings;
  GVariant *state;

  G_APPLICATION_CLASS (photos_application_parent_class)
    ->startup (application);

  gegl_init (NULL, NULL);

  grl_init (NULL, NULL);
  registry = grl_registry_get_default ();
  error = NULL;
  if (!grl_registry_load_plugin_by_id (registry, "grl-flickr", &error))
    {
      g_warning ("Unable to load Grilo's Flickr plugin: %s", error->message);
      g_error_free (error);
    }

  priv->settings = g_settings_new ("org.gnome.desktop.background");

  priv->resource = photos_get_resource ();
  g_resources_register (priv->resource);

  settings = gtk_settings_get_default ();
  g_object_set (settings, "gtk-application-prefer-dark-theme", TRUE, NULL);

  priv->facebook_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                           G_DBUS_PROXY_FLAGS_NONE,
                                                           "org.gnome.OnlineMiners.Facebook",
                                                           "/org/gnome/OnlineMiners/Facebook",
                                                           NULL,
                                                           NULL);

  priv->flickr_miner = gom_miner_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                                         G_DBUS_PROXY_FLAGS_NONE,
                                                         "org.gnome.OnlineMiners.Flickr",
                                                         "/org/gnome/OnlineMiners/Flickr",
                                                         NULL,
                                                         NULL);

  priv->item_mngr = photos_item_manager_dup_singleton ();

  /* A dummy reference to keep it alive during the lifetime of the
   * application.
   */
  priv->camera_cache = photos_camera_cache_dup_singleton ();

  priv->mode_cntrlr = photos_mode_controller_dup_singleton ();

  action = g_simple_action_new ("about", NULL);
  g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_application_about), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
  g_object_unref (action);

  priv->fs_action = g_simple_action_new ("fullscreen", NULL);
  g_signal_connect_swapped (priv->fs_action, "activate", G_CALLBACK (photos_application_fullscreen), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->fs_action));

  g_signal_connect_swapped (priv->mode_cntrlr,
                            "can-fullscreen-changed",
                            G_CALLBACK (photos_application_can_fullscreen_changed),
                            self);

  state = g_variant_new ("b", FALSE);
  priv->gear_action = g_simple_action_new_stateful ("gear-menu", NULL, state);
  g_signal_connect (priv->gear_action, "activate", G_CALLBACK (photos_application_action_toggle), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->gear_action));

  priv->open_action = g_simple_action_new ("open-current", NULL);
  g_signal_connect_swapped (priv->open_action, "activate", G_CALLBACK (photos_application_open_current), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->open_action));

  priv->print_action = g_simple_action_new ("print-current", NULL);
  g_signal_connect_swapped (priv->print_action, "activate", G_CALLBACK (photos_application_print_current), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->print_action));

  priv->properties_action = g_simple_action_new ("properties", NULL);
  g_signal_connect_swapped (priv->properties_action, "activate", G_CALLBACK (photos_application_properties), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->properties_action));

  priv->remote_display_action = g_simple_action_new ("remote-display-current", NULL);
  g_signal_connect_swapped (priv->remote_display_action, "activate", G_CALLBACK (photos_application_remote_display_current), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->remote_display_action));

  action = g_simple_action_new ("quit", NULL);
  g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_application_quit), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
  g_object_unref (action);

  state = g_variant_new ("b", FALSE);
  priv->search_action = g_simple_action_new_stateful ("search", NULL, state);
  g_signal_connect (priv->search_action, "activate", G_CALLBACK (photos_application_action_toggle), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->search_action));

  priv->sel_all_action = g_simple_action_new ("select-all", NULL);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->sel_all_action));

  priv->sel_none_action = g_simple_action_new ("select-none", NULL);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->sel_none_action));

  priv->set_bg_action = g_simple_action_new ("set-background", NULL);
  g_signal_connect_swapped (priv->set_bg_action, "activate", G_CALLBACK (photos_application_set_bg), self);
  g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (priv->set_bg_action));

  g_signal_connect_swapped (priv->mode_cntrlr,
                            "window-mode-changed",
                            G_CALLBACK (photos_application_window_mode_changed),
                            self);

  photos_application_init_app_menu (self);

  gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>q", "app.quit", NULL);
  gtk_application_add_accelerator (GTK_APPLICATION (self), "F11", "app.fullscreen", NULL);
  gtk_application_add_accelerator (GTK_APPLICATION (self), "F10", "app.gear-menu", NULL);
  gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>p", "app.print-current", NULL);
  gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>f", "app.search", NULL);
  gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>a", "app.select-all", NULL);
}
Ejemplo n.º 27
0
Archivo: start.c Proyecto: y20k/ezeedo
/**
 * Sets up the application when it first starts
 */
void
startup (GApplication *app,
         gpointer      user_data)
{
    // get ezeedo from user data
    ezeedo_wrapper_structure *ezeedo;
    ezeedo = user_data;

    // define widgets
    GMenu *menu;
    GMenu *section;

    // define actions
    GSimpleAction *preferences_action;
    GSimpleAction *quit_action;

    // create application menu
    menu = g_menu_new ();

    // create section
    section = g_menu_new ();

    // contruct application menu
    g_menu_append         (section,
                           "About",
                           "win.about");
    g_menu_append         (section,
                           "Quit",
                           "app.quit");
    g_menu_append         (menu,
                           "Preferences",
                           "app.preferences");
    g_menu_append_section (menu,
                           NULL,
                           G_MENU_MODEL (section));

    // create actions
    preferences_action = g_simple_action_new ("preferences",
                                              NULL);
    g_signal_connect (preferences_action, "activate",
                      G_CALLBACK(show_preferences_dialog), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(app),
                             G_ACTION(preferences_action));

    // activate ctrl-q
    const gchar* quit_accels[2] = { "<Ctrl>Q", NULL };
    gtk_application_set_accels_for_action (GTK_APPLICATION(app),
                                           "app.quit",
                                           quit_accels);

    quit_action = g_simple_action_new ("quit",
                                       NULL);
    g_signal_connect        (quit_action, "activate",
                             G_CALLBACK (quit_application), ezeedo);
    g_action_map_add_action (G_ACTION_MAP(app),
                             G_ACTION(quit_action));

    // Set menu for the overall application
    gtk_application_set_app_menu (GTK_APPLICATION(app),
                                  G_MENU_MODEL(menu));

    return;
}
Ejemplo n.º 28
0
Archivo: start.c Proyecto: y20k/ezeedo
/**
 * Creates empty main application window
 */
GtkWidget
*create_mainwindow (ezeedo_wrapper_structure *ezeedo)
{
    // define widgets
    GtkWidget *window;
    GtkWidget *headerbar;
    GtkWidget *windowmenu_button;
    GtkWidget *stack;
    GtkWidget *stackswitcher;

    GtkWidget *todo_stack;
    GtkWidget *todo_paned;
    GtkWidget *todolist_scrollbox;
    GtkWidget *todolist_box;
    GtkWidget *categories_scrollbox;
    GtkWidget *categories_box;
    GtkWidget *task_entry;

    GtkWidget *done_stack;
    GtkWidget *donelist_scrollbox;
    GtkWidget *donelist_box;

    GtkWidget *archive_button;

    // define action
    GSimpleAction *about_action;

    // get window size and position from gsettings store
    GSettings     *settings;
    gint width;
    gint height;
    gint x;
    gint y;
    gint sidebar_size;

    settings     = g_settings_new     ("org.y20k.ezeedo");
    width        = g_settings_get_int (settings,
                                       "main-window-width");
    height       = g_settings_get_int (settings,
                                       "main-window-height");
    x            = g_settings_get_int (settings,
                                       "main-window-position-y");
    y            = g_settings_get_int (settings,
                                       "main-window-position-y");
    sidebar_size = g_settings_get_int (settings,
                                       "sidebar-size");
    g_object_unref (settings);

    // create main window with title and default size
    window = gtk_application_window_new (ezeedo->application);
    gtk_window_set_title        (GTK_WINDOW (window),
                                 "Ezeedo");
    gtk_window_set_icon_name    (GTK_WINDOW (window),
                                 EZEEDOICON);
    gtk_window_set_default_size (GTK_WINDOW (window),
                                 width,
                                 height);
    gtk_window_move             (GTK_WINDOW (window),
                                 x,
                                 y);

    // create headerbar and stack switcher
    headerbar       = gtk_header_bar_new ();
    gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(headerbar),
                                          true);
    stackswitcher   = gtk_stack_switcher_new ();

    // create stack for todo and done
    stack = gtk_stack_new ();

    // create stack for todolist
    todo_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                              0);

    // create paned container for left and right columns of todo tab
    todo_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
    gtk_paned_set_position (GTK_PANED(todo_paned),
                            sidebar_size);

    // create categories scrollbox and box for left pane
    categories_scrollbox = gtk_scrolled_window_new (NULL,
                                                    NULL);
    categories_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                  0);

    // create todolist scrollbox and box for right pane
    todolist_scrollbox = gtk_scrolled_window_new (NULL,
                                                  NULL);
    todolist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                0);

    // create task entry
    task_entry = gtk_entry_new ();
    gtk_widget_set_margin_start       (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_end         (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_top         (GTK_WIDGET(task_entry),
                                       10);
    gtk_widget_set_margin_bottom      (GTK_WIDGET(task_entry),
                                       10);
    gtk_entry_set_placeholder_text    (GTK_ENTRY(task_entry),
                                       "Enter new task");
    gtk_entry_set_max_length          (GTK_ENTRY(task_entry),
                                       TASKLENGTH);
    gtk_widget_grab_focus (task_entry);
 
    // create stack for donelist
    done_stack = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                  0);

    // create donelist scrollbox and box
    donelist_scrollbox = gtk_scrolled_window_new (NULL,
                                                  NULL);
    donelist_box = gtk_box_new (GTK_ORIENTATION_VERTICAL,
                                0);

    // create archive button
    archive_button = gtk_button_new_with_label ("Archive all done tasks");
    gtk_widget_set_margin_start  (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_end    (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_top    (GTK_WIDGET (archive_button),
                                  10);
    gtk_widget_set_margin_bottom (GTK_WIDGET (archive_button),
                                  10);

    // add some widgets to ezeedo wrapper structure
    ezeedo->window = window;
    ezeedo->todo_paned = todo_paned;
    ezeedo->categories_box = categories_box;
    ezeedo->todolist_box = todolist_box;
    ezeedo->donelist_box = donelist_box;

    // create window menu
    windowmenu_button = create_windowmenu (ezeedo);

    // create about action and connect about action signal
    about_action = g_simple_action_new ("about",
                                        NULL); 
    g_action_map_add_action (G_ACTION_MAP (window),
                             G_ACTION (about_action));
    g_signal_connect (about_action, "activate",
                      G_CALLBACK (show_about_window), window);

    // detect entry signal
    g_signal_connect (task_entry, "activate",
                      G_CALLBACK (add_task_entry), ezeedo);

    // detect archive button pressed
    g_signal_connect (archive_button, "clicked",
                      G_CALLBACK (display_info_dialog), "Task archival is not supported yet.");
 
    // detect window close
    g_signal_connect (G_OBJECT (window), "delete-event",
                      G_CALLBACK (close_window), ezeedo);


    // construct headerbar for main window
    gtk_window_set_titlebar   (GTK_WINDOW(window),
                               headerbar);
    gtk_header_bar_pack_start (GTK_HEADER_BAR(headerbar),
                               stackswitcher);
    gtk_header_bar_pack_end   (GTK_HEADER_BAR(headerbar),
                               windowmenu_button);

    // add stack to main window
    gtk_container_add (GTK_CONTAINER(window),
                       stack);

    // set stack switcher and populate stack with todolist and donelist
    gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER(stackswitcher),
                                  GTK_STACK(stack));
    gtk_stack_add_titled         (GTK_STACK(stack),
                                  todo_stack,
                                  "To do",
                                  "To do");
    gtk_stack_add_titled         (GTK_STACK(stack),
                                  done_stack,
                                  "Done",
                                  "Done");

    // construct main todo stack
    gtk_container_add (GTK_CONTAINER(todo_stack),
                       todo_paned);

    gtk_paned_add1   (GTK_PANED(todo_paned),
                      categories_scrollbox);
    gtk_paned_add2   (GTK_PANED(todo_paned),
                      todolist_scrollbox);

    // add box to scrollable box
    gtk_container_add (GTK_CONTAINER(todolist_scrollbox),
                       todolist_box);

    // add task entry to todo stack
    gtk_container_add (GTK_CONTAINER(todo_stack),
                       task_entry);

    // add box to scrollable box
    gtk_container_add (GTK_CONTAINER(categories_scrollbox),
                       categories_box);

    // construct main donelist stack
    gtk_container_add (GTK_CONTAINER(done_stack),
                       donelist_scrollbox);
    gtk_container_add (GTK_CONTAINER(donelist_scrollbox),
                       donelist_box);

    return (window); 
}
static void rotation_plugin_real_activate (PeasActivatable* base) {
	RotationPlugin * self;
	TotemObject* t = NULL;
	GObject* _tmp0_ = NULL;
	GObject* _tmp1_ = NULL;
	gchar* mrl = NULL;
	TotemObject* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	GMenu* menu = NULL;
	TotemObject* _tmp4_ = NULL;
	GMenu* _tmp5_ = NULL;
	GMenu* _tmp6_ = NULL;
	TotemObject* _tmp7_ = NULL;
	GtkWidget* _tmp8_ = NULL;
	BaconVideoWidget* _tmp9_ = NULL;
	GSimpleAction* _tmp10_ = NULL;
	GSimpleAction* _tmp11_ = NULL;
	TotemObject* _tmp12_ = NULL;
	GSimpleAction* _tmp13_ = NULL;
	TotemObject* _tmp14_ = NULL;
	GSimpleAction* _tmp15_ = NULL;
	GSimpleAction* _tmp16_ = NULL;
	TotemObject* _tmp17_ = NULL;
	GSimpleAction* _tmp18_ = NULL;
	TotemObject* _tmp19_ = NULL;
	GMenuItem* item = NULL;
	const gchar* _tmp20_ = NULL;
	GMenuItem* _tmp21_ = NULL;
	GMenuItem* _tmp22_ = NULL;
	GMenu* _tmp23_ = NULL;
	GMenuItem* _tmp24_ = NULL;
	const gchar* _tmp25_ = NULL;
	GMenuItem* _tmp26_ = NULL;
	GMenuItem* _tmp27_ = NULL;
	GMenu* _tmp28_ = NULL;
	GMenuItem* _tmp29_ = NULL;
	const gchar* _tmp30_ = NULL;
	const gchar* _tmp33_ = NULL;
	TotemObject* _tmp35_ = NULL;
	TotemObject* _tmp36_ = NULL;
	self = (RotationPlugin*) base;
	g_object_get ((PeasActivatable*) self, "object", &_tmp0_, NULL);
	_tmp1_ = _tmp0_;
	t = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, totem_object_get_type (), TotemObject);
	_tmp2_ = t;
	_tmp3_ = totem_object_get_current_mrl (_tmp2_);
	mrl = _tmp3_;
	_tmp4_ = t;
	_tmp5_ = totem_object_get_menu_section (_tmp4_, "rotation-placeholder");
	_tmp6_ = _g_object_ref0 (_tmp5_);
	menu = _tmp6_;
	_tmp7_ = t;
	_tmp8_ = totem_object_get_video_widget (_tmp7_);
	_tmp9_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, BACON_TYPE_VIDEO_WIDGET) ? ((BaconVideoWidget*) _tmp8_) : NULL;
	if (_tmp9_ == NULL) {
		_g_object_unref0 (_tmp8_);
	}
	_g_object_unref0 (self->priv->bvw);
	self->priv->bvw = _tmp9_;
	_tmp10_ = g_simple_action_new ("rotate-left", NULL);
	_g_object_unref0 (self->priv->rotate_left_action);
	self->priv->rotate_left_action = _tmp10_;
	_tmp11_ = self->priv->rotate_left_action;
	g_signal_connect_object (_tmp11_, "activate", (GCallback) _rotation_plugin_cb_rotate_left_g_simple_action_activate, self, 0);
	_tmp12_ = t;
	_tmp13_ = self->priv->rotate_left_action;
	g_action_map_add_action ((GActionMap*) _tmp12_, (GAction*) _tmp13_);
	_tmp14_ = t;
	gtk_application_add_accelerator ((GtkApplication*) _tmp14_, "<Primary><Shift>R", "app.rotate-left", NULL);
	_tmp15_ = g_simple_action_new ("rotate-right", NULL);
	_g_object_unref0 (self->priv->rotate_right_action);
	self->priv->rotate_right_action = _tmp15_;
	_tmp16_ = self->priv->rotate_right_action;
	g_signal_connect_object (_tmp16_, "activate", (GCallback) _rotation_plugin_cb_rotate_right_g_simple_action_activate, self, 0);
	_tmp17_ = t;
	_tmp18_ = self->priv->rotate_right_action;
	g_action_map_add_action ((GActionMap*) _tmp17_, (GAction*) _tmp18_);
	_tmp19_ = t;
	gtk_application_add_accelerator ((GtkApplication*) _tmp19_, "<Primary>R", "app.rotate-right", NULL);
	_tmp20_ = _ ("_Rotate ↷");
	_tmp21_ = g_menu_item_new (_tmp20_, "app.rotate-right");
	item = _tmp21_;
	_tmp22_ = item;
	g_menu_item_set_attribute (_tmp22_, "accel", "s", "<Primary>R", NULL);
	_tmp23_ = menu;
	_tmp24_ = item;
	g_menu_append_item (_tmp23_, _tmp24_);
	_tmp25_ = _ ("Rotate ↶");
	_tmp26_ = g_menu_item_new (_tmp25_, "app.rotate-left");
	_g_object_unref0 (item);
	item = _tmp26_;
	_tmp27_ = item;
	g_menu_item_set_attribute (_tmp27_, "accel", "s", "<Primary><Shift>R", NULL);
	_tmp28_ = menu;
	_tmp29_ = item;
	g_menu_append_item (_tmp28_, _tmp29_);
	_tmp30_ = mrl;
	if (_tmp30_ == NULL) {
		GSimpleAction* _tmp31_ = NULL;
		GSimpleAction* _tmp32_ = NULL;
		_tmp31_ = self->priv->rotate_right_action;
		g_simple_action_set_enabled (_tmp31_, FALSE);
		_tmp32_ = self->priv->rotate_left_action;
		g_simple_action_set_enabled (_tmp32_, FALSE);
	}
	_tmp33_ = mrl;
	if (_tmp33_ != NULL) {
		const gchar* _tmp34_ = NULL;
		_tmp34_ = mrl;
		rotation_plugin_try_restore_state (self, _tmp34_, ____lambda6__gasync_ready_callback, g_object_ref (self));
	}
	_tmp35_ = t;
	g_signal_connect_object (_tmp35_, "file-closed", (GCallback) _rotation_plugin_cb_file_closed_totem_object_file_closed, self, 0);
	_tmp36_ = t;
	g_signal_connect_object (_tmp36_, "file-opened", (GCallback) _rotation_plugin_cb_file_opened_totem_object_file_opened, self, 0);
	_g_object_unref0 (item);
	_g_object_unref0 (menu);
	_g_free0 (mrl);
	_g_object_unref0 (t);
}
Ejemplo n.º 30
0
static void
impl_activate (PeasActivatable *plugin)
{
	TotemMoviePropertiesPlugin *pi;
	TotemObject *totem;
	GtkWindow *parent;
	GMenu *menu;
	GMenuItem *item;

	pi = TOTEM_MOVIE_PROPERTIES_PLUGIN (plugin);
	totem = g_object_get_data (G_OBJECT (plugin), "object");

	pi->priv->props = bacon_video_widget_properties_new ();
	gtk_widget_show (pi->priv->props);
	gtk_widget_set_sensitive (pi->priv->props, FALSE);

	parent = totem_object_get_main_window (totem);
	pi->priv->dialog = gtk_dialog_new_with_buttons (_("Properties"),
							parent,
							GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
							NULL,
							GTK_RESPONSE_CLOSE,
							NULL);
	g_object_unref (parent);
	g_signal_connect (pi->priv->dialog, "delete-event",
			  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
	g_signal_connect (pi->priv->dialog, "response",
			  G_CALLBACK (gtk_widget_hide_on_delete), NULL);
	gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (pi->priv->dialog))),
			   pi->priv->props);

	/* Properties action */
	pi->priv->props_action = g_simple_action_new ("properties", NULL);
	g_signal_connect (G_OBJECT (pi->priv->props_action), "activate",
			  G_CALLBACK (properties_action_cb), pi);
	g_action_map_add_action (G_ACTION_MAP (totem), G_ACTION (pi->priv->props_action));
	gtk_application_add_accelerator (GTK_APPLICATION (totem),
					 "<Primary>p",
					 "app.properties",
					 NULL);
	/* FIXME: Handle GDK_KEY_View */

	/* Install the menu */
	menu = totem_object_get_menu_section (totem, "properties-placeholder");
	item = g_menu_item_new (_("_Properties"), "app.properties");
	g_menu_item_set_attribute (item, "accel", "s", "<Primary>p");
	g_menu_append_item (G_MENU (menu), item);
	g_object_unref (item);

	g_signal_connect (G_OBJECT (totem),
			  "file-opened",
			  G_CALLBACK (totem_movie_properties_plugin_file_opened),
			  plugin);
	g_signal_connect (G_OBJECT (totem),
			  "file-closed",
			  G_CALLBACK (totem_movie_properties_plugin_file_closed),
			  plugin);
	g_signal_connect (G_OBJECT (totem),
			  "metadata-updated",
			  G_CALLBACK (totem_movie_properties_plugin_metadata_updated),
			  plugin);
	pi->priv->handler_id_stream_length = g_signal_connect (G_OBJECT (totem),
							       "notify::stream-length",
							       G_CALLBACK (stream_length_notify_cb),
							       plugin);
}