Exemplo n.º 1
1
static void
bloat_pad_startup (GApplication *application)
{
  GtkBuilder *builder;

  G_APPLICATION_CLASS (bloat_pad_parent_class)
    ->startup (application);

  g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application);

  builder = gtk_builder_new ();
  gtk_builder_add_from_string (builder,
                               "<interface>"
                               "  <menu id='app-menu'>"
                               "    <section>"
                               "      <item label='_New Window' action='app.new' accel='<Primary>n'/>"
                               "    </section>"
                               "    <section>"
                               "      <item label='_About Bloatpad' action='app.about'/>"
                               "    </section>"
                               "    <section>"
                               "      <item label='_Quit' action='app.quit' accel='<Primary>q'/>"
                               "    </section>"
                               "  </menu>"
                               "  <menu id='menubar'>"
                               "    <submenu label='_Edit'>"
                               "      <section>"
                               "        <item label='_Copy' action='win.copy' accel='<Primary>c'/>"
                               "        <item label='_Paste' action='win.paste' accel='<Primary>v'/>"
                               "      </section>"
                               "    </submenu>"
                               "    <submenu label='_View'>"
                               "      <section>"
                               "        <item label='_Fullscreen' action='win.fullscreen'/>"
                               "      </section>"
                               "    </submenu>"
                               "  </menu>"
                               "</interface>", -1, NULL);
  gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
  gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
  g_object_unref (builder);
}
Exemplo n.º 2
1
int main( int argc, char** argv )
{
    if( argc == 2 )
    {
        if( strcmp( argv[1], "-v" ) == 0 || strcmp( argv[1], "--version" ) == 0 )
        {
            show_version();
            return( SUCCESS );
        }
    }
    else if( argc != 1 )
    {
        g_print( "Error! Unknown argument: \"%s\"\n", argv[1] );
        show_using();
        return( SUCCESS );
    }

    gdk_threads_init();
    gtk_init( &argc, &argv );
    GtkBuilder* builder = gtk_builder_new();

    if( !gtk_builder_add_from_string( builder, ui, -1, &global.error_msg ) ) {
        g_warning( "%s\n", global.error_msg->message );
        global.error_msg = NULL;
        return( BUILDER_LOAD_FAIL );
    }

    page_connection_bind( builder );
    page_keyboard_bind( builder );
    page_shell_bind( builder );
    grab_window_bind( builder );
    preferences_window_bind( builder );
    aboutdialog_bind( builder );

    gtk_builder_connect_signals( builder, NULL );
    show_in_statusbar( READY_MESSAGE );
    g_object_unref( builder );
    gtk_main();

    return( SUCCESS );
}
Exemplo n.º 3
0
static GtkBuilder *gtkhash_properties_init_builder(void)
{
#if (GTK_MAJOR_VERSION > 2)
	return gtk_builder_new_from_resource(PROPERTIES_XML_RESOURCE);
#else
	GError *error = NULL;
	GBytes *bytes = g_resources_lookup_data(PROPERTIES_XML_RESOURCE,
		G_RESOURCE_LOOKUP_FLAGS_NONE, &error);

	if (G_UNLIKELY(error)) {
		g_warning("%s", error->message);
		g_error_free(error);

		return NULL;
	}

	gsize xml_len = 0;
	char *xml = g_bytes_unref_to_data(bytes, &xml_len);
	GtkBuilder *builder = gtk_builder_new();

	gtk_builder_add_from_string(builder, xml, xml_len, &error);
	g_free(xml);

	if (G_UNLIKELY(error)) {
		g_warning("%s", error->message);
		g_error_free(error);
		g_object_unref(builder);

		return NULL;
	}

	return builder;
#endif
}
Exemplo n.º 4
0
static GObject *
get_toplevel_from_string (GladePreviewer *app, gchar *name, gchar *string, gsize size)
{
  gchar *wd = NULL;
  GObject *retval;

  /* We need to change the working directory so builder get a chance to load resources */
  if (app->file_name)
    {
      gchar *dirname = g_path_get_dirname (app->file_name);
      wd = g_get_current_dir ();
      g_chdir (dirname);
      g_free (dirname);
    }

  /* We use template flag as a hint since the user can turn on and off template
   * while the preview is live.
   */
  retval = (app->is_template) ? glade_preview_template_object_new (string, size) : NULL;

  if (!retval)
    {
      GtkBuilder *builder = gtk_builder_new ();
      GError *error = NULL;

      /* We do not know if its a template yet */
      app->is_template = FALSE;

      if (gtk_builder_add_from_string (builder, string, size, &error))
        retval = get_toplevel (builder, name);
      else
        {
          if (error->code == GTK_BUILDER_ERROR_UNHANDLED_TAG &&
              (retval = glade_preview_template_object_new (string, size)))
            {
              /* At this point we know it is a template, so keep a hint for next time */
              app->is_template = TRUE;
            }
          else
            {
              gchar *message = g_strdup_printf (_("Couldn't load builder definition: %s"), error->message);
              glade_preview_window_set_message (app->window, GTK_MESSAGE_ERROR, message);
              g_free (message);
            }

          g_error_free (error);
        }

      g_object_unref (builder);
    }

  /* restore directory */
  if (wd)
    {
      g_chdir (wd);
      g_free (wd);
    }
  
  return retval;
}
Exemplo n.º 5
0
static gboolean
apply_ui_from_file (GtkBuilder *gui, GsfInput *src, const char *uifile,
		    GError **error)
{
	gboolean res;
	GsfInput *orig_src;

	if (!src)
		return FALSE;

	orig_src = g_object_ref (src);
	src = gsf_input_uncompress (src);
	if (uifile && src == orig_src) {
		/*
		 * This is sad, but see bugs 662503 and 662679.  Since
		 * ui files can contain relative filenames we must use
		 * the _file interface to load such files.  Do not
		 * compress such files for the time being.
		 */
		res = gtk_builder_add_from_file (gui, uifile, error);
	} else {
		size_t size = gsf_input_size (src);
		gconstpointer data = gsf_input_read (src, size, NULL);
		res = gtk_builder_add_from_string (gui, data, size, error);
	}
	g_object_unref (src);
	g_object_unref (orig_src);
	return res;
}
Exemplo n.º 6
0
void
pfi_gui_make ( void )
{
    extern const char pfi_gtk_gui[];
    GtkBuilder * b;
    int i;
    
    pfi_mutex = g_mutex_new();
    
    /* Create the interface builder */
    b = gtk_builder_new();
    
    /* Load spec */
    gtk_builder_add_from_string( b, pfi_gtk_gui, -1, NULL );
    
    /* Grab symbols */
    for( i = 0; syms[i].symname; i++ )
        *syms[i].stor = (GtkWidget*)gtk_builder_get_object( b, syms[i].symname );
    
    system( "touch pfilog.txt" );
    
    gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(pfi_gui_e_file), "pfilog.txt" );
    gtk_spin_button_set_range( GTK_SPIN_BUTTON(pfi_gui_e_arg_start), 0.0, 3.0 ); 
    
    gtk_widget_set_sensitive( pfi_gui_b_disable, FALSE );
    
    g_signal_connect( G_OBJECT(pfi_gui_window), "delete-event", (GCallback)delete_event, NULL );
    g_signal_connect( G_OBJECT(pfi_gui_b_close), "clicked", (GCallback)close, NULL );
    g_signal_connect( G_OBJECT(pfi_gui_b_enable), "clicked", (GCallback)enable, NULL );
    g_signal_connect( G_OBJECT(pfi_gui_b_disable), "clicked", (GCallback)disable, NULL );
}
Exemplo n.º 7
0
static void
set_xml_string(GelUIGeneric *self, const gchar *xml_string)
{
	g_return_if_fail(GEL_UI_IS_GENERIC(self));
	g_return_if_fail(xml_string != NULL);

	GelUIGenericPrivate *priv = self->priv;
	g_return_if_fail(priv->builder == NULL);

	priv->builder = gtk_builder_new();

	GError *error = NULL;
	if (!gtk_builder_add_from_string(priv->builder, xml_string, -1, &error))
	{
		g_warning(_("Cannot load UI from string: %s"), error->message);
		g_error_free(error);
		return;
	}

	GtkWidget *w = GTK_WIDGET(gtk_builder_get_object(priv->builder, "main-widget"));
	if (w == NULL)
	{
		g_warning(_("Cannot find widget 'main-widget' on UI"));
		return;
	}

	gtk_widget_reparent(w, (GtkWidget *) self);
	gtk_box_set_child_packing ((GtkBox *) self, w, TRUE, TRUE, 0, GTK_PACK_START);

	g_object_notify(G_OBJECT(self), "xml-string");
}
Exemplo n.º 8
0
GtkBuilder*
create_builder_or_die(const gchar * name)
{
	guint res = 0;
	GValue *gval;
	GError *error = NULL;
	const gchar *ghb_ui;

    const gchar *markup =
        N_("<b><big>Unable to create %s.</big></b>\n"
        "\n"
        "Internal error. Could not parse UI description.\n"
		"%s");
	g_debug("create_builder_or_die ()\n");
	GtkBuilder *xml = gtk_builder_new();
	gval = ghb_resource_get("ghb-ui");
	ghb_ui = g_value_get_string(gval);
	if (xml != NULL)
		res = gtk_builder_add_from_string(xml, ghb_ui, -1, &error);
    if (!xml || !res) 
	{
        GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL,
            GTK_DIALOG_MODAL,
            GTK_MESSAGE_ERROR,
            GTK_BUTTONS_CLOSE,
            _(markup),
            name, error->message);
        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
        exit(EXIT_FAILURE);
    }
    return xml;
}
Exemplo n.º 9
0
static void
activate (GApplication *app,
          gpointer      user_data)
{
    GtkWidget *win;
    GtkWidget *button;
    GSimpleActionGroup *doc_actions;
    GtkBuilder *builder;
    GMenuModel *doc_menu;
    GMenuModel *win_menu;
    GMenu *button_menu;
    GMenuItem *section;

    if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL)
        return;

    win = gtk_application_window_new (GTK_APPLICATION (app));

    doc_actions = g_simple_action_group_new ();
    g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win);

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

    builder = gtk_builder_new ();
    gtk_builder_add_from_string (builder, menu_ui, -1, NULL);

    doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu"));
    win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu"));

    button_menu = g_menu_new ();

    section = g_menu_item_new_section (NULL, doc_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "doc");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    section = g_menu_item_new_section (NULL, win_menu);
    g_menu_item_set_attribute (section, "action-namespace", "s", "win");
    g_menu_append_item (button_menu, section);
    g_object_unref (section);

    button = gtk_menu_button_new ();
    gtk_button_set_label (GTK_BUTTON (button), "Menu");
    gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions));
    gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu));

    gtk_container_add (GTK_CONTAINER (win), button);
    gtk_container_set_border_width (GTK_CONTAINER (win), 12);
    gtk_widget_show_all (win);

    g_object_unref (button_menu);
    g_object_unref (doc_actions);
    g_object_unref (builder);
}
GtkWidget* PythonCompletionFramework::create_config_widget(GtkDialog* dialog)
{
    g_debug("code complete: plugin_configure");
    JediCompletePluginPref* pref = JediCompletePluginPref::instance();

    GError* err = NULL;
    GtkBuilder* builder = gtk_builder_new();
    // here defines prefpy_ui, prefpy_ui_len
#include "data/prefpy_ui.hpp"
    gint ret = gtk_builder_add_from_string(builder, (gchar*)prefpy_ui, prefpy_ui_len, &err);
    if (err) {
	    printf("fail to load preference ui: %s\n", err->message);
	    GtkWidget* vbox = gtk_vbox_new(FALSE, 5);
	    return vbox;
    }

    // suggestion window
    pref_widgets.row_text_max_spinbtn = GETOBJ("spin_rowtextmax");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.row_text_max_spinbtn),
			      pref->row_text_max);

    pref_widgets.swin_height_max_spinbtn = GETOBJ("spin_sugwinheight");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.swin_height_max_spinbtn),
			      pref->suggestion_window_height_max);

	pref_widgets.page_up_down_skip_amount_spinbtn = GETOBJ("spin_pageupdownskipamount");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.page_up_down_skip_amount_spinbtn),
			      pref->page_up_down_skip_amount);
    // python
    pref_widgets.start_with_dot = GETOBJ("cbtn_dot");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pref_widgets.start_with_dot),
				 pref->start_completion_with_dot);

    GtkWidget* pypath_entry = GETOBJ("te_pypath");
    pref_widgets.pypath_buffer = gtk_entry_get_buffer(GTK_ENTRY(pypath_entry));
    gtk_entry_set_text(GTK_ENTRY(pypath_entry), pref->python_path.c_str());

    GtkWidget* file_choose_button = GETOBJ("btn_filesel");
    g_signal_connect(file_choose_button, "clicked", G_CALLBACK(on_click_file_choose_button), NULL);

    pref_widgets.port_spinbtn = GETOBJ("spin_port");
    gtk_spin_button_set_value(GTK_SPIN_BUTTON(pref_widgets.port_spinbtn),
			      pref->jedi_server_port);

    GtkWidget* reinstall_button = GETOBJ("btn_reinstall");
    g_signal_connect(reinstall_button, "clicked", G_CALLBACK(on_click_exec_button), NULL);

    g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), this);
    GtkWidget* vbox = GETOBJ("box_prefpy");
    return vbox;
}
Exemplo n.º 11
0
static GMenuModel *
get_model (void)
{
  GError *error = NULL;
  GtkBuilder *builder;
  GMenuModel *menu;

  builder = gtk_builder_new ();
  gtk_builder_add_from_string (builder, menu_markup, -1, &error);
  g_assert_no_error (error);

  menu = g_object_ref (gtk_builder_get_object (builder, "edit-menu"));
  g_object_unref (builder);

  return menu;
}
Exemplo n.º 12
0
static void
ekiga_window_init_menu (EkigaWindow *mw)
{
  mw->priv->builder = gtk_builder_new ();
  gtk_builder_add_from_string (mw->priv->builder, win_menu, -1, NULL);

  g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()),
                           g_settings_create_action (mw->priv->video_devices_settings->get_g_settings (),
                                                     "enable-preview"));
  g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()),
                           g_settings_create_action (mw->priv->user_interface_settings->get_g_settings (),
                                                     "panel-section"));

  gtk_widget_insert_action_group (GTK_WIDGET (mw), "win",
                                  G_ACTION_GROUP (g_application_get_default ()));
}
Exemplo n.º 13
0
static void
test_clicked (GtkWidget     *button, 
	      TestInterface *interface)
{
  if (!interface->window)
    {
      GtkBuilder *builder = gtk_builder_new ();
      
      gtk_builder_add_from_string (builder, interface->interface, -1, NULL);
      interface->window = (GtkWidget *)gtk_builder_get_object (builder, "window");

      g_signal_connect (interface->window, "delete_event", 
			G_CALLBACK (gtk_widget_hide_on_delete), NULL);
    }

  gtk_widget_show (interface->window);
}
Exemplo n.º 14
0
static void
startup (GApplication *app)
{
  GtkBuilder *builder;
  GMenuModel *appmenu;
  GMenuModel *menubar;

  builder = gtk_builder_new ();
  gtk_builder_add_from_string (builder, ui_info, -1, NULL);

  appmenu = (GMenuModel *)gtk_builder_get_object (builder, "appmenu");
  menubar = (GMenuModel *)gtk_builder_get_object (builder, "menubar");

  gtk_application_set_app_menu (GTK_APPLICATION (app), appmenu);
  gtk_application_set_menubar (GTK_APPLICATION (app), menubar);

  g_object_unref (builder);
}
Exemplo n.º 15
0
static void
panel_applet_init (PanelApplet *applet)
{
	GtkStyleContext *context;

	applet->priv = PANEL_APPLET_GET_PRIVATE (applet);

	applet->priv->flags  = PANEL_APPLET_FLAGS_NONE;
	applet->priv->orient = PANEL_APPLET_ORIENT_UP;
	applet->priv->has_handle = FALSE;

	applet->priv->builder = gtk_builder_new ();
	gtk_builder_add_from_string (applet->priv->builder, panel_menu_ui, -1, NULL);

	applet->priv->action_group = g_simple_action_group_new ();

	gtk_widget_set_events (GTK_WIDGET (applet), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);

	context = gtk_widget_get_style_context (GTK_WIDGET (applet));
	gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
}
Exemplo n.º 16
0
GMenuModel *
Ekiga::GActorMenu::get_model (const Ekiga::GActorMenuStore & store,
                              bool display_section_label)
{
  int c = 0;
  std::string content = as_xml (std::string (), display_section_label);

  for (Ekiga::GActorMenuStore::const_iterator it = store.begin ();
       it != store.end ();
       it++) {
    content = content + (*it)->as_xml (std::string (), display_section_label);
    c += (*it)->size ();
  }
  content = "<?xml_content version=\"1.0\"?>"
            "<interface>"
            "  <menu id=\"menu\">" + content + "</menu>"
            "</interface>";

  gtk_builder_add_from_string (builder, content.c_str (), -1, NULL);
  return (n > 0 || c > 0 ? G_MENU_MODEL (gtk_builder_get_object (builder, "menu")) : NULL);
}
Exemplo n.º 17
0
/**
 * panel_applet_setup_menu:
 * @applet: a #PanelApplet.
 * @xml: a menu XML string..
 *
 * Sets up the context menu of @applet. @xml is a #GtkUIManager UI definition,
 * describing how to display the menu items. @action_group contains the
 * various #GtkAction that are referenced in @xml.
 *
 * See also the <link linkend="getting-started.context-menu">Context
 * Menu</link> section.
 **/
void
panel_applet_setup_menu (PanelApplet *applet,
                         const gchar *xml)
{
	gchar  *new_xml;
	GError *error = NULL;

	g_return_if_fail (PANEL_IS_APPLET (applet));
	g_return_if_fail (xml != NULL);

	gtk_widget_insert_action_group (GTK_WIDGET (applet), "applet", G_ACTION_GROUP (applet->priv->action_group));

	new_xml = g_strdup_printf ("<interface><menu id=\"panel-applet-popup\">%s</menu></interface>\n", xml);
	gtk_builder_add_from_string (applet->priv->builder, new_xml, -1, &error);
	g_free (new_xml);

	if (error) {
		g_warning ("Error merging menus: %s\n", error->message);
		g_error_free (error);
	}
}
Exemplo n.º 18
0
int main (int argc, char *argv[])
{
   gtk_init (&argc, &argv);

   GtkBuilder * builder = gtk_builder_new();
   if (gtk_builder_add_from_string(builder, ui, -1, 0) == 0)
   {
      std::cout << "Failed to load UI" << std::endl;
      return 1;
   }

   GtkWidget * widget = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
   g_signal_connect(widget, "destroy", G_CALLBACK(gtk_main_quit), NULL);

   g_object_unref(builder);

   gtk_widget_show(GTK_WIDGET(widget));

   gtk_main();

   return 0;
}
Exemplo n.º 19
0
GtkBuilder*
create_builder_or_die(const gchar * name)
{
    guint res = 0;
    GError *error = NULL;
    const gchar *ghb_ui;
    gsize data_size;

    ghb_ui_register_resource();
    GResource *ui_res = ghb_ui_get_resource();
    GBytes *gbytes = g_resource_lookup_data(ui_res, "/org/handbrake/ui/ghb.ui",
                                            0, NULL);
    ghb_ui = g_bytes_get_data(gbytes, &data_size);

    const gchar *markup =
        N_("<b><big>Unable to create %s.</big></b>\n"
        "\n"
        "Internal error. Could not parse UI description.\n"
        "%s");
    g_debug("create_builder_or_die()\n");
    GtkBuilder *xml = gtk_builder_new();
    if (xml != NULL)
        res = gtk_builder_add_from_string(xml, ghb_ui, -1, &error);
    if (!xml || !res)
    {
        GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL,
            GTK_DIALOG_MODAL,
            GTK_MESSAGE_ERROR,
            GTK_BUTTONS_CLOSE,
            gettext(markup),
            name, error->message);
        gtk_dialog_run(GTK_DIALOG(dialog));
        gtk_widget_destroy(dialog);
        exit(EXIT_FAILURE);
    }
    return xml;
}
Exemplo n.º 20
0
/* test that overlays can be constructed with GtkBuilder */
static GtkWidget *
test_builder (void)
{
  GtkBuilder *builder;
  GtkWidget *win;
  GError *error;

  builder = gtk_builder_new ();

  error = NULL;
  if (!gtk_builder_add_from_string (builder, buffer, -1, &error))
    {
      g_warning ("%s", error->message);
      g_error_free (error);
      return NULL;
    }

  win = (GtkWidget *)gtk_builder_get_object (builder, "window");
  g_object_ref (win);

  g_object_unref (builder);

  return win;
}
Exemplo n.º 21
0
static void init_ui( squidge_t *sq )
{
	GtkBuilder *builder;
	PangoFontDescription *pf;
	GtkAdjustment *v;

	builder = gtk_builder_new();
	g_assert( gtk_builder_add_from_string( builder, squidge_gtkbuilder, -1, NULL ) );

	obj( GTK_WINDOW, win );
	obj( GTK_NOTEBOOK, notebook );
	obj( GTK_IMAGE, splash );
	obj( GTK_TEXT_VIEW, log_textview );
	obj( GTK_SCROLLED_WINDOW, log_scroll );

	sq->ui.text_buffer = gtk_text_view_get_buffer(sq->ui.log_textview);
	load_splash(sq);
	camview_init( &sq->camview, builder );

	/* We want a monospace font */
	pf = pango_font_description_from_string("Monospace 10");
	g_assert( pf != NULL );
	gtk_widget_modify_font( GTK_WIDGET(sq->ui.log_textview), pf );
	pango_font_description_free( pf );

	/* We want the value-changed signal so we can stop following the bottom */
	v = gtk_scrolled_window_get_vadjustment( sq->ui.log_scroll );
	g_signal_connect( v, "value-changed",
			  G_CALLBACK(vert_value_changed), sq );
	g_signal_connect( v, "changed",
			  G_CALLBACK(vert_changed), sq );

	gtk_builder_connect_signals( builder, sq );
	g_object_unref( G_OBJECT(builder) );
	gtk_widget_show( GTK_WIDGET(sq->ui.win) );
}
static GtkWidget * build_properties_area(WBPlugin *wb, const gchar *buffer, gsize length) {
    GError *error = NULL;
    GObject *area = NULL;
    GtkRadioButton *only_maximized, *active_window;
    GtkToggleButton *show_on_desktop, *sync_wm_theme;
    GtkTreeSelection *selection;
    GtkCellRenderer *renderer;
    GtkListStore *list_store;
    GtkWidget *view, *theme_name_treeview;
    GtkEntry *button_layout;

    wb->prefs->builder = gtk_builder_new();

    if (gtk_builder_add_from_string(wb->prefs->builder, buffer, length, &error)) {
        area = gtk_builder_get_object(wb->prefs->builder, "alignment0");

        if (G_LIKELY (area != NULL))
        {
            only_maximized = GTK_RADIO_BUTTON(gtk_builder_get_object(wb->prefs->builder, "only_maximized"));
            active_window = GTK_RADIO_BUTTON(gtk_builder_get_object(wb->prefs->builder, "active_window"));

            if (G_LIKELY (only_maximized != NULL))
            {
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(only_maximized), wb->prefs->only_maximized);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(active_window), !wb->prefs->only_maximized);
                g_signal_connect(only_maximized, "toggled", G_CALLBACK(on_only_maximized_toggled), wb);
            }
            else {
                DBG("No widget with the name \"only_maximized\" found");
            }

            show_on_desktop = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wb->prefs->builder, "show_on_desktop"));

            if (G_LIKELY (show_on_desktop != NULL)) {
                gtk_toggle_button_set_active(show_on_desktop, wb->prefs->show_on_desktop);
                g_signal_connect(show_on_desktop, "toggled", G_CALLBACK(on_show_on_desktop_toggled), wb);
            }
            else {
                DBG("No widget with the name \"show_on_desktop\" found");
            }

            /* Style widgets */
            theme_name_treeview = GTK_WIDGET (gtk_builder_get_object (wb->prefs->builder, "theme_name_treeview"));

            /* theme name */
            {
            list_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
            gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (list_store), COL_THEME_NAME,
                                             (GtkTreeIterCompareFunc) wckbuttons_theme_sort_func,
                                             NULL, NULL);
            gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), COL_THEME_NAME, GTK_SORT_ASCENDING);
            gtk_tree_view_set_model (GTK_TREE_VIEW (theme_name_treeview), GTK_TREE_MODEL (list_store));
            g_object_unref (G_OBJECT (list_store));

            renderer = gtk_cell_renderer_text_new ();

            gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (theme_name_treeview),
                                                         0, _("Directory"), renderer, "text", 1, NULL);
            gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (theme_name_treeview),
                                                         0, _("Themes usable"), renderer, "text", 0, NULL);
            selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (theme_name_treeview));
            g_signal_connect (selection, "changed", G_CALLBACK (wckbuttons_theme_selection_changed),
                              wb);
            gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
            view = GTK_WIDGET (gtk_builder_get_object (wb->prefs->builder, "theme_name_treeview"));
            wckbuttons_load_themes (view, wb);
            }

            sync_wm_theme = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wb->prefs->builder, "sync_wm_theme"));

            if (G_LIKELY (sync_wm_theme != NULL))
            {
                if (wb->wm_channel)
                {
                    gtk_toggle_button_set_active(sync_wm_theme, wb->prefs->sync_wm_theme);
                    g_signal_connect(sync_wm_theme, "toggled", G_CALLBACK(on_sync_theme_with_wm_toggled), wb);
                }
                else {
                    gtk_widget_set_sensitive (GTK_WIDGET(sync_wm_theme), FALSE);
                }
            }
            else {
                DBG("No widget with the name \"sync_wm_theme\" found");
            }

            button_layout = GTK_ENTRY(gtk_builder_get_object(wb->prefs->builder, "button_layout"));

            if (G_LIKELY (button_layout != NULL))
            {
                gtk_entry_set_text(button_layout, wb->prefs->button_layout);
                g_signal_connect(GTK_EDITABLE(button_layout), "changed", G_CALLBACK(on_button_layout_changed), wb);
            }
            else {
                DBG("No widget with the name \"button_layout\" found");
            }

            return GTK_WIDGET(area) ;
        }
        else {
            g_set_error_literal(&error, 0, 0, "No widget with the name \"contentarea\" found");
        }
    }

    g_critical("Faild to construct the builder for plugin %s-%d: %s.", xfce_panel_plugin_get_name (wb->plugin), xfce_panel_plugin_get_unique_id (wb->plugin), error->message);
    g_error_free(error);
    g_object_unref(G_OBJECT (wb->prefs->builder) );

    return NULL ;
}
Exemplo n.º 23
0
/********************************
* AL_Sprite_Add
*
@ sprite_rect: rectangle draw in editor
@ parent: name of sheet.
*/
void AL_Sprite_Add( Spritesheet * spritesheet, GdkRectangle * sprite_rect )
{
	if ( !spritesheet || !mokoiBasePath )
	{
		Meg_Error_Print( __func__, __LINE__, "AL_Sheet_AddSprite: Invalid parent" );
		return;
	}

	GtkWidget * dialog, * text_name, * file_mask, *check_maskauto, * file_entity, * radio_align;
	GtkSpinButton * spin_mask, * spin_x, * spin_y, * spin_w, * spin_h, * spin_frames;

	/* UI */
	GError * error = NULL;
	GtkBuilder * ui = gtk_builder_new();

	if ( !gtk_builder_add_from_string( ui, mokoiUI_SpriteAdd, -1, &error ) )
	{
		Meg_Error_Print( __func__, __LINE__, "UI creation error '%s'.", error->message );
		return;
	}


	dialog = GET_WIDGET( ui, "mokoi_sheet_addchild");
	text_name = GET_WIDGET( ui, "text_name");

	spin_x = GET_SPIN_WIDGET( ui, "spin_x");
	spin_y = GET_SPIN_WIDGET( ui, "spin_y");
	spin_w = GET_SPIN_WIDGET( ui, "spin_w");
	spin_h = GET_SPIN_WIDGET( ui, "spin_h");
	spin_mask = GET_SPIN_WIDGET( ui, "spin_mask");
	spin_frames = GET_SPIN_WIDGET( ui, "spin_frames");

	check_maskauto = GET_WIDGET( ui, "check_maskauto");

	file_mask = GET_WIDGET( ui, "file_mask");
	file_entity = GET_WIDGET( ui, "file_entity");

	radio_align = GET_WIDGET( ui, "radio_align");

	/* Set Default Values */
	gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file_mask), mokoiBasePath );
	gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file_entity), mokoiBasePath );

	gtk_spin_button_set_value( spin_x, (gdouble)sprite_rect->x );
	gtk_spin_button_set_value( spin_y, (gdouble)sprite_rect->y );
	gtk_spin_button_set_value( spin_w, (gdouble)sprite_rect->width );
	gtk_spin_button_set_value( spin_h, (gdouble)sprite_rect->height );

	/* Show Dialog */
	gtk_widget_show_all( gtk_dialog_get_content_area( GTK_DIALOG(dialog) ) );
	gtk_window_set_transient_for( GTK_WINDOW(dialog), Meg_Main_GetWindow());
	if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_APPLY )
	{
		gboolean bool_horizontal = FALSE;
		const gchar * sprite_name;
		gchar * mask_file, * entity_file;
		gint frame_count = 0;

		sprite_name = gtk_entry_get_text( GTK_ENTRY(text_name) );
		mask_file = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file_mask) );
		entity_file = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file_entity) );
		frame_count = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_frames) );
		bool_horizontal = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radio_align) );

		if ( !g_utf8_strlen(sprite_name, -1) )
		{
			Meg_Error_Print( __func__, __LINE__, "AL_Sheet_AddSprite: No name given" );
		}
		else
		{
			SheetObject * sprite = NULL;
			SpriteData * sprite_data = g_new0(SpriteData, 1);

			sprite = SheetObject_New( (gpointer)sprite_data, &SpriteData_FreePointer );

			sprite->parent_sheet = g_strdup( spritesheet->file );
			sprite->display_name = g_strdup( sprite_name );

			sprite->ident_string = g_strdup_printf( "%s:%s", sprite->parent_sheet, sprite->display_name );

			if ( entity_file )
				sprite_data->entity = g_path_get_basename( entity_file );
			else
				sprite_data->entity = NULL;

			sprite->visible = TRUE;
			sprite_data->image_loaded = FALSE;

			sprite->position.x = gtk_spin_button_get_value_as_int( spin_x );
			sprite->position.y = gtk_spin_button_get_value_as_int( spin_y );
			sprite->position.width = gtk_spin_button_get_value_as_int( spin_w );
			sprite->position.height = gtk_spin_button_get_value_as_int( spin_h );

			if ( mask_file && g_utf8_strlen( mask_file, -1 ) )
				sprite_data->mask.name = g_strdup(mask_file);
			else
			{
				sprite_data->mask.value = gtk_spin_button_get_value_as_int( spin_mask );
				sprite_data->mask.autogen = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check_maskauto) );
			}

			GdkPixbuf * parent_image = AL_GetImage( sprite->parent_sheet, NULL );
			if ( frame_count > 0 )
			{
				/* Creating Animation */
				gint frame_length = 0;
				if ( bool_horizontal )
				{
					frame_length = sprite->position.width / frame_count;
					sprite->position.width = frame_length;
				}
				else
				{
					frame_length = sprite->position.height / frame_count;
					sprite->position.height = frame_length;
				}
				sprite_data->animation = g_new0(AnimationDetail, 1);


				gint q = 0;
				while ( q < frame_count )
				{
					/* Create the sprite for the frame */
					SheetObject * frame_sprite = NULL;
					SpriteData * frame_sprite_data = g_new0(SpriteData, 1);

					frame_sprite = SheetObject_New( (gpointer)frame_sprite_data, &SpriteData_FreePointer );

					frame_sprite->display_name = g_strdup_printf("%s_%d", sprite->display_name, q);
					frame_sprite->parent_sheet = g_strdup( spritesheet->file );
					frame_sprite->ident_string = g_strdup_printf( "%s:%s", frame_sprite->parent_sheet, frame_sprite->display_name );
					frame_sprite->visible = FALSE;

					frame_sprite_data->mask = sprite_data->mask;
					frame_sprite_data->image_loaded = FALSE;

					if ( bool_horizontal )
					{
						frame_sprite->position.x = sprite_rect->x + (q * frame_length);
						frame_sprite->position.y = sprite_rect->y;
						frame_sprite->position.width = frame_length;
						frame_sprite->position.height = sprite_rect->height;
					}
					else
					{
						frame_sprite->position.x = sprite_rect->x;
						frame_sprite->position.y = sprite_rect->y + (q * frame_length);
						frame_sprite->position.width = sprite_rect->width;
						frame_sprite->position.height = frame_length;
					}

					frame_sprite_data->image = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, frame_sprite->position.width, frame_sprite->position.height );
					gdk_pixbuf_copy_area( parent_image, frame_sprite->position.x, frame_sprite->position.y, frame_sprite->position.width, frame_sprite->position.height, frame_sprite_data->image, 0, 0);
					frame_sprite_data->image_loaded = TRUE;

					spritesheet->children = g_slist_append( spritesheet->children, frame_sprite);

					/* Create the Frame and append to list */
					AnimationFrame * frame = g_new0( AnimationFrame, 1 );
					frame->sprite = g_strdup( frame_sprite->display_name );
					frame->offset.x = 0;
					frame->offset.y = 0;
					frame->length_ms = 1000;
					frame->f = 0;
					sprite_data->animation->frames = g_slist_append( sprite_data->animation->frames, frame);

					q++;
				}
			}
			else
			{
				/* Create Sprite */
				sprite_data->image = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, sprite->position.width, sprite->position.height );
				gdk_pixbuf_copy_area( parent_image, sprite->position.x, sprite->position.y, sprite->position.width, sprite->position.height, sprite_data->image, 0, 0 );
				sprite_data->image_loaded = TRUE;
			}
			g_object_unref( parent_image );

			spritesheet->children = g_slist_append( spritesheet->children, sprite );
			Sheet_SaveFile( spritesheet );
		}
	}
	gtk_widget_destroy( dialog );
}
Exemplo n.º 24
0
gint
main (gint argc, gchar **argv)
{
    GObject    *dialog, *plug_child;
    GtkWidget  *plug;
    GtkBuilder *builder;
    GError     *error = NULL;

    /* setup translation domain */
    xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");

    /* initialize Gtk+ */
    if(!gtk_init_with_args (&argc, &argv, "", entries, PACKAGE, &error))
    {
        if (G_LIKELY (error))
        {
            /* print error */
            g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message);
            g_print (_("Type '%s --help' for usage."), G_LOG_DOMAIN);
            g_print ("\n");

            /* cleanup */
            g_error_free (error);
        }
        else
        {
            g_error ("Unable to open display.");
        }

        return EXIT_FAILURE;
    }

    /* check if we should print version information */
    if (G_UNLIKELY (opt_version))
    {
        g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ());
        g_print ("%s\n", "Copyright (c) 2008-2011");
        g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved."));
        g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT);
        g_print ("\n");

        return EXIT_SUCCESS;
    }

    /* initialize xfconf */
    if (!xfconf_init (&error))
    {
        /* print error and exit */
        g_error ("Failed to connect to xfconf daemon: %s.", error->message);
        g_error_free (error);

        return EXIT_FAILURE;
    }

    /* open the channels */
    accessibility_channel = xfconf_channel_new ("accessibility");
    session_channel = xfconf_channel_new ("xfce4-session");

    /* hook to make sure the libxfce4ui library is linked */
    if (xfce_titled_dialog_get_type () == 0)
        return EXIT_FAILURE;

    /* load the Gtk user-interface file */
    builder = gtk_builder_new ();
    if (gtk_builder_add_from_string (builder, accessibility_dialog_ui,
                                     accessibility_dialog_ui_length, &error) != 0)
    {
        /* Configure widgets */
        accessibility_settings_dialog_configure_widgets (builder);

        if (G_UNLIKELY (opt_socket_id == 0))
        {
            /* Get the dialog widget */
            dialog = gtk_builder_get_object (builder, "dialog");

            g_signal_connect (dialog, "response",
                G_CALLBACK (accessibility_settings_dialog_response), NULL);
            gtk_window_present (GTK_WINDOW (dialog));

            /* To prevent the settings dialog to be saved in the session */
            gdk_set_sm_client_id ("FAKE ID");

            gtk_main ();
        }
        else
        {
            /* Create plug widget */
            plug = gtk_plug_new (opt_socket_id);
            g_signal_connect (plug, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
            gtk_widget_show (plug);

            /* Stop startup notification */
            gdk_notify_startup_complete ();

            /* Get plug child widget */
            plug_child = gtk_builder_get_object (builder, "plug-child");
            gtk_widget_reparent (GTK_WIDGET (plug_child), plug);
            gtk_widget_show (GTK_WIDGET (plug_child));

            /* To prevent the settings dialog to be saved in the session */
            gdk_set_sm_client_id ("FAKE ID");

            /* Enter main loop */
            gtk_main ();
        }
    }
    else
    {
        g_error ("Failed to load the UI file: %s.", error->message);
        g_error_free (error);
    }

    /* Release Builder */
    g_object_unref (G_OBJECT (builder));

    /* release the channels */
    g_object_unref (G_OBJECT (accessibility_channel));
    g_object_unref (G_OBJECT (session_channel));

    /* shutdown xfconf */
    xfconf_shutdown();

    return EXIT_SUCCESS;
}
Exemplo n.º 25
0
static gboolean on_show_dlg (FmProgressDisplay *data)
{
    GtkBuilder *builder = gtk_builder_new ();
    GtkWidget *to, *to_label;
    FmPath *dest;
    const char *title = NULL;
    GtkTextTagTable *tag_table = gtk_text_tag_table_new ();

    gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
    gtk_builder_add_from_string (builder, PROGRESS_DLG, -1, NULL);

    data->dlg = (GtkWidget*) gtk_builder_get_object (builder, "dlg");

    g_signal_connect (data->dlg, "response", (GCallback) on_response, data);

    to_label =              (GtkWidget*) gtk_builder_get_object (builder, "to_label");
    to =                    (GtkWidget*) gtk_builder_get_object (builder, "dest");
    data->icon =            (GtkWidget*) gtk_builder_get_object (builder, "icon");
    data->msg =             (GtkWidget*) gtk_builder_get_object (builder, "msg");
    data->act =             (GtkWidget*) gtk_builder_get_object (builder, "action");
    data->src =             (GtkWidget*) gtk_builder_get_object (builder, "src");
    data->dest =            (GtkWidget*) gtk_builder_get_object (builder, "dest");
    data->current =         (GtkWidget*) gtk_builder_get_object (builder, "current");
    data->progress =        (GtkWidget*) gtk_builder_get_object (builder, "progress");
    data->error_pane =      (GtkWidget*) gtk_builder_get_object (builder, "error_pane");
    data->error_msg =       (GtkWidget*) gtk_builder_get_object (builder, "error_msg");
    data->remaining_time =  (GtkWidget*) gtk_builder_get_object (builder, "remaining_time");

    data->bold_tag = gtk_text_tag_new ("bold");
    g_object_set (data->bold_tag, "weight", PANGO_WEIGHT_BOLD, NULL);
    
    gtk_text_tag_table_add (tag_table, data->bold_tag);
    data->error_buf = gtk_text_buffer_new (tag_table);
    g_object_unref (tag_table);
    
    gtk_text_view_set_buffer (GTK_TEXT_VIEW (data->error_msg), data->error_buf);

    g_object_unref (builder);

    // set the src label
    if (data->job->srcs)
    {
        GList *l = fm_list_peek_head_link (data->job->srcs);
        int i;
        char *disp;
        FmPath *path;
        
        GString *str = g_string_sized_new (512);
        path = FM_PATH (l->data);
        disp = fm_path_display_basename (path);
        g_string_assign (str, disp);
        g_free (disp);
        
        for ( i =1, l=l->next; i < 10 && l; l=l->next, ++i)
        {
            path = FM_PATH (l->data);
            g_string_append (str, _(", "));
            disp = fm_path_display_basename (path);
            g_string_append (str, disp);
            g_free (disp);
        }
        
        if (l)
            g_string_append (str, "...");
        
        gtk_label_set_text (GTK_LABEL (data->src), str->str);
        g_string_free (str, TRUE);
    }

    // FIXME_pcm: use accessor functions instead
    switch (data->job->type)
    {
        case FM_FILE_OP_MOVE:
            title = _("Moving files");
        break;
        
        case FM_FILE_OP_COPY:
            title = _("Copying files");
        break;
        
        case FM_FILE_OP_TRASH:
            title = _("Trashing files");
        break;
        
        case FM_FILE_OP_DELETE:
            title = _("Deleting files");
        break;
        
        case FM_FILE_OP_LINK:
            title = _("Creating symlinks");
        break;
        
        case FM_FILE_OP_CHANGE_ATTR:
            title = _("Changing file attributes");
        break;
    }
    
    if (title)
    {
        gtk_window_set_title (GTK_WINDOW (data->dlg), title);
        gtk_label_set_text (GTK_LABEL (data->act), title);
    }

    if (dest = fm_file_ops_job_get_dest (data->job))
    {
        char *dest_str = fm_path_display_name (dest, TRUE);
        gtk_label_set_text (GTK_LABEL (to), dest_str);
        g_free (dest_str);
    }
    else
    {
        gtk_widget_destroy (data->dest);
        gtk_widget_destroy (to_label);
    }

    gtk_window_present (GTK_WINDOW (data->dlg));
    data->update_timeout = g_timeout_add (500,  (GSourceFunc)on_update_dlg, data);

    data->delay_timeout = 0;
    return FALSE;
}
Exemplo n.º 26
0
static gint on_ask_rename (FmFileOpsJob *job, FmFileInfo *src, FmFileInfo *dest, char **new_name, FmProgressDisplay *data)
{
    int res;
    GtkBuilder *builder = gtk_builder_new ();
    GtkWidget *dlg, *src_icon, *dest_icon, *src_fi, *dest_fi, *filename, *apply_all;
    char *tmp;
    const char *disp_size;

    // return default operation if the user has set it
    if (data->default_opt)
        return data->default_opt;

    if (data->timer)
        g_timer_stop (data->timer);

    gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
    ensure_dlg (data);

    gtk_builder_add_from_string  (builder, RENAME_DLG, -1, NULL);
    dlg =       (GtkWidget*)gtk_builder_get_object (builder, "dlg");
    src_icon =  (GtkWidget*)gtk_builder_get_object (builder, "src_icon");
    src_fi =    (GtkWidget*)gtk_builder_get_object (builder, "src_fi");
    dest_icon = (GtkWidget*)gtk_builder_get_object (builder, "dest_icon");
    dest_fi =   (GtkWidget*)gtk_builder_get_object (builder, "dest_fi");
    filename =  (GtkWidget*)gtk_builder_get_object (builder, "filename");
    apply_all = (GtkWidget*)gtk_builder_get_object (builder, "apply_all");
    
    gtk_window_set_transient_for (GTK_WINDOW (dlg), (GtkWindow*) data->dlg);

    gtk_image_set_from_gicon (GTK_IMAGE (src_icon), fm_file_info_get_gicon (src), GTK_ICON_SIZE_DIALOG);
    disp_size = fm_file_info_get_disp_size (src);
    if (disp_size)
    {
        tmp = g_strdup_printf (_("Type: %s\nSize: %s\nModified: %s"),
                              fm_file_info_get_desc (src),
                              disp_size,
                              fm_file_info_get_disp_mtime (src));
    }
    else
    {
        tmp = g_strdup_printf (_("Type: %s\nModified: %s"),
                              fm_file_info_get_desc (src),
                              fm_file_info_get_disp_mtime (src));
    }

    gtk_label_set_text (GTK_LABEL (src_fi), tmp);
    g_free (tmp);

    gtk_image_set_from_gicon (GTK_IMAGE (dest_icon), fm_file_info_get_gicon (src), GTK_ICON_SIZE_DIALOG);
    disp_size = fm_file_info_get_disp_size (dest);
    if (disp_size)
    {
        tmp = g_strdup_printf (_("Type: %s\nSize: %s\nModified: %s"),
                              fm_file_info_get_desc (dest),
                              fm_file_info_get_disp_size (dest),
                              fm_file_info_get_disp_mtime (dest));
    }
    else
    {
        tmp = g_strdup_printf (_("Type: %s\nModified: %s"),
                              fm_file_info_get_desc (dest),
                              fm_file_info_get_disp_mtime (dest));
    }

    gtk_label_set_text (GTK_LABEL (dest_fi), tmp);
    g_free (tmp);

    tmp = g_filename_display_name (dest->path->name);
    gtk_entry_set_text (GTK_ENTRY (filename), tmp);
    g_free (tmp);
    
    g_object_set_data (G_OBJECT (filename), "old_name", dest->disp_name);
    g_signal_connect (filename, "changed", (GCallback) on_filename_changed, gtk_builder_get_object (builder, "rename"));

    g_object_unref (builder);

    res = gtk_dialog_run (GTK_DIALOG (dlg));
    switch (res)
    {
        case RESPONSE_RENAME:
            *new_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (filename)));
            res = FM_FILE_OP_RENAME;
        break;
        
        case RESPONSE_OVERWRITE:
            res = FM_FILE_OP_OVERWRITE;
        break;
        
        case RESPONSE_SKIP:
            res = FM_FILE_OP_SKIP;
        break;
        
        default:
            res = FM_FILE_OP_CANCEL;
    }

    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (apply_all)))
    {
        if (res == RESPONSE_OVERWRITE || res == FM_FILE_OP_SKIP)
            data->default_opt = res;
    }

    gtk_widget_destroy (dlg);

    if (data->timer)
        g_timer_continue (data->timer);

    return res;
}
Exemplo n.º 27
0
/********************************
* Meg_MapSection_New
* Initialises new Map Section/Overview Tab
*/
GtkWidget * Meg_MapSection_Open( gchar * file )
{
	GtkWidget * widget_overview, * label_text, * display_overview;

	GError * error = NULL;
	GtkBuilder * ui = gtk_builder_new();
	if ( !gtk_builder_add_from_string( ui, alchera_map_overview_ui, -1, &error ) )
	{
		Meg_Error_Print( __func__, __LINE__, "UI creation error: %s", error->message );
		return NULL;
	}

	widget_overview = GET_WIDGET( ui, "overview" );
	label_text = GET_WIDGET( ui, "alchera-label");
	display_overview = GET_WIDGET( ui, "display_overview" );

	/* Tab Settings */
	g_signal_connect( G_OBJECT(widget_overview), "key-release-event", G_CALLBACK(Meg_Main_HelpRequest), NULL);
	g_object_set_data( G_OBJECT(widget_overview), "meg-help-page", g_strdup(PROGRAMSHELPDIRECTORY"/Worlds.xml") );
	g_object_ref( widget_overview );

	/* Set names */
	Meg_Misc_SetLabel( label_text, "World:", file, ' ' );

	guint32 section_id = 0;
	section_id = AL_MapSection_Open( file, Meg_Misc_ParentWindow( sectionNotebook ) );

	gint width = -1, height = -1;
	AL_MapSection_SizeRequest( section_id, &width, &height );
	gtk_widget_set_size_request( display_overview, width, height );
	//gtk_widget_get_preferred_size

	//GtkRequisition requisition;
	//gtk_widget_size_request(display_overview,&requisition);/* FIX: GTK3 */

	/* Signals */
#if GTK_MAJOR_VERSION == 2
	g_signal_connect( display_overview, "expose-event", G_CALLBACK(Meg_MapSection_LayoutExpose), widget_overview );
#else
	g_signal_connect( display_overview, "draw", G_CALLBACK(Meg_MapSection_LayoutDraw), widget_overview );
#endif
	g_signal_connect( display_overview, "button-press-event", G_CALLBACK(Meg_MapSection_LayoutPressed), widget_overview );
	g_signal_connect( display_overview, "key-release-event", G_CALLBACK(Meg_MapSection_LayoutPressed), widget_overview );
	g_signal_connect( display_overview, "button-release-event", G_CALLBACK(Meg_MapSection_LayoutPressed), widget_overview );
	g_signal_connect( display_overview, "key-press-event", G_CALLBACK(Meg_MapSection_LayoutPressed), widget_overview );
	g_signal_connect( display_overview, "popup-menu", G_CALLBACK(Meg_MapSection_LayoutPressed), widget_overview );

	SET_OBJECT_SIGNAL(ui, "button_save", "clicked", G_CALLBACK(Meg_MapSection_ButtonSave), widget_overview );
	SET_OBJECT_SIGNAL(ui, "button_zoomin", "clicked", G_CALLBACK(Meg_MapSection_ButtonZoomIn), widget_overview );
	SET_OBJECT_SIGNAL(ui, "button_zoom", "clicked", G_CALLBACK(Meg_MapSection_ButtonZoomNormal), widget_overview );
	SET_OBJECT_SIGNAL(ui, "button_zoomout", "clicked", G_CALLBACK(Meg_MapSection_ButtonZoomOut), widget_overview );

	SET_OBJECT_SIGNAL(ui, "combo_type", "changed", G_CALLBACK(Meg_MapSection_ComboType), widget_overview );

	/* Notebook Label */
	GtkWidget * notebook_label, * notebook_box, * notebook_close, * notebook_image;

	notebook_label = gtk_label_new(NULL);
	Meg_Misc_SetLabel( notebook_label, "Section", file, ' ' );

	notebook_close = gtk_event_box_new();
	notebook_image = gtk_image_new_from_stock( GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU );
	gtk_container_add( GTK_CONTAINER(notebook_close), notebook_image);
	g_signal_connect( G_OBJECT(notebook_close), "button_press_event", G_CALLBACK(Meg_MapSection_CloseTab), widget_overview);

	notebook_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);

	gtk_container_add( GTK_CONTAINER(notebook_box), notebook_label);
	gtk_container_add( GTK_CONTAINER(notebook_box), notebook_close);
	gtk_widget_show_all( notebook_box );

	g_object_set_data( G_OBJECT(widget_overview), "alchera-section-id", GUINT_TO_POINTER(section_id) );
	g_object_set_data( G_OBJECT(widget_overview), "alchera-section-name", g_strdup(file) );


	gtk_notebook_append_page( GTK_NOTEBOOK(sectionNotebook), widget_overview, notebook_box );
	gtk_widget_queue_draw(widget_overview);
	return widget_overview;
}
Exemplo n.º 28
0
Arquivo: view.c Projeto: mrirecon/view
extern struct view_s* window_new(const char* name, long* pos, const long dims[DIMS], const complex float* x)
{
	struct view_s* v = create_view(name, pos, dims, x);

	GtkBuilder* builder = gtk_builder_new();
	// gtk_builder_add_from_file(builder, "viewer.ui", NULL);
	gtk_builder_add_from_string(builder, viewer_gui, -1, NULL);

	v->gtk_drawingarea = GTK_WIDGET(gtk_builder_get_object(builder, "drawingarea1"));
	v->gtk_viewport = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1"));

	v->gtk_winlow = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "winlow"));
	v->gtk_winhigh = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "winhigh"));

	v->gtk_entry = GTK_ENTRY(gtk_builder_get_object(builder, "entry"));
	PangoFontDescription* desc = pango_font_description_new();
	pango_font_description_set_family(desc, "mono");
	pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
	pango_font_description_set_absolute_size(desc, 10 * PANGO_SCALE);
	gtk_widget_override_font(GTK_WIDGET(v->gtk_entry), desc);
	pango_font_description_free(desc);

	v->gtk_zoom = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "zoom"));
	v->gtk_aniso = GTK_ADJUSTMENT(gtk_builder_get_object(builder, "aniso"));

	v->gtk_mode = GTK_COMBO_BOX(gtk_builder_get_object(builder, "mode"));
	gtk_combo_box_set_active(v->gtk_mode, 0);

	v->gtk_flip = GTK_COMBO_BOX(gtk_builder_get_object(builder, "flip"));
	gtk_combo_box_set_active(v->gtk_flip, 0);

	v->gtk_transpose = GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builder, "transpose"));

	for (int j = 0; j < DIMS; j++) {

		char pname[10];
		snprintf(pname, 10, "pos%02d", j);
		v->gtk_posall[j] = GTK_ADJUSTMENT(gtk_builder_get_object(builder, pname));
		gtk_adjustment_set_upper(v->gtk_posall[j], v->dims[j] - 1);
		gtk_adjustment_set_value(v->gtk_posall[j], 0);

		snprintf(pname, 10, "check%02d", j);
		v->gtk_checkall[j] = GTK_CHECK_BUTTON(gtk_builder_get_object(builder, pname));
	}

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(v->gtk_checkall[v->xdim]), TRUE);
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(v->gtk_checkall[v->ydim]), TRUE);

	gtk_builder_connect_signals(builder, v);

	GtkWindow* window = GTK_WINDOW(gtk_builder_get_object(builder, "window1"));
	g_object_unref(G_OBJECT(builder));

	gtk_window_set_title(window, name);

	gtk_widget_show(GTK_WIDGET(window));

	nr_windows++;

	refresh_callback(NULL, v);
	geom_callback(NULL, v);
	window_callback(NULL, v);

	return v;
}
Exemplo n.º 29
0
static void
GyahtzeeCreateMainWindow (void)
{
  GtkWidget *hbox, *vbox;
  GtkWidget *toolbar;
  GtkWidget *tmp;
  GtkWidget *dicebox;
  GtkAccelGroup *accel_group;
  GtkBuilder *builder;
  GtkUIManager *ui_manager;
  int i, j;

  window = gtk_application_window_new (application);
  gtk_window_set_application (GTK_WINDOW (window), application);
  gtk_window_set_title (GTK_WINDOW (window), _(appName));
  gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), TRUE);

  //games_conf_add_window (GTK_WINDOW (window), NULL);

  g_signal_connect (G_OBJECT (window), "delete_event",
		    G_CALLBACK (quit_game), NULL);
  g_signal_connect (G_OBJECT (window), "key_press_event",
		    G_CALLBACK (key_press), NULL);

  statusbar = gtk_statusbar_new ();
  ui_manager = gtk_ui_manager_new ();
  builder = gtk_builder_new ();
  gtk_builder_add_from_string (builder, builder_description, -1, NULL);

  games_stock_prepare_for_statusbar_tooltips (ui_manager, statusbar);

	/*---- Menus ----*/
  create_menus (ui_manager);
  accel_group = gtk_ui_manager_get_accel_group (ui_manager);
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
  g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application);
  gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));

	/*---- Content ----*/

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), vbox);

  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);

  gtk_widget_show (statusbar);
  /* Retreive dice pixmaps from memory or files */
  LoadDicePixmaps ();

  /* Put all the dice in a vertical column */
  dicebox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start (GTK_BOX (hbox), dicebox, FALSE, TRUE, 0);
  gtk_widget_show (dicebox);

  rollLabel = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (rollLabel), TRUE);
  gtk_widget_show (rollLabel);
  gtk_box_pack_start (GTK_BOX (dicebox), rollLabel, FALSE, TRUE, 5);

  mbutton = gtk_button_new_with_label (_("Roll!"));
  gtk_box_pack_end (GTK_BOX (dicebox), mbutton, FALSE, FALSE, 5);
  g_signal_connect (G_OBJECT (mbutton), "clicked",
		    G_CALLBACK (roll_dice), NULL);
  gtk_widget_show (GTK_WIDGET (mbutton));

  toolbar = gtk_toolbar_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar),
			       GTK_ORIENTATION_VERTICAL);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
  gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), FALSE);
  gtk_box_pack_end (GTK_BOX (dicebox), toolbar, TRUE, TRUE, 0);

  for (i = 0; i < NUMBER_OF_DICE; i++) {
    tmp = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

    for (j = 0; j < NUMBER_OF_PIXMAPS; j++) {
      gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_YAHTZEE], FALSE, FALSE, 0);
      gtk_box_pack_start (GTK_BOX (tmp), dicePixmaps[i][j][GAME_KISMET], FALSE, FALSE, 0);
    }

    diceBox[i] = gtk_toggle_tool_button_new ();
    gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (diceBox[i]), tmp);
    g_signal_connect (G_OBJECT (diceBox[i]), "clicked",
		      G_CALLBACK (modify_dice), &DiceValues[i]);

    gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
			GTK_TOOL_ITEM (diceBox[i]), -1);

    gtk_widget_show (GTK_WIDGET (diceBox[i]));
    gtk_widget_show (tmp);
  /*gtk_widget_show (dicePixmaps[i][0][game_type]);*/
  }
  gtk_widget_show (toolbar);

  /* Scores displayed in score list */
  ScoreList = create_score_list ();
  gtk_box_pack_end (GTK_BOX (hbox), ScoreList, TRUE, TRUE, 0);
  setup_score_list (ScoreList);
  gtk_widget_show (ScoreList);

  gtk_widget_show (hbox);
  gtk_widget_show (vbox);

  gtk_widget_show (window);

  GyahtzeeNewGame ();
}
Exemplo n.º 30
0
/* Main entry point */
int main(int argc, char** argv) {
	GtkWidget *window;
	GtkAccelGroup *group;
	struct eid_vwr_ui_callbacks* cb;
	pthread_t thread;
	GdkPixbuf *logo;
	GError* err = NULL;

	/* The GNU implementation of setlocale() ignores whatever we
	 * specify if the LANGUAGE environment variable has a value, so
	 * ensure that it doesn't
	 */
	putenv("LANGUAGE=");
	bindtextdomain("eid-viewer", DATAROOTDIR "/locale");
	textdomain("eid-viewer");

	eid_vwr_convert_set_lang(langfromenv());

	gtk_init(&argc, &argv);
	builder = gtk_builder_new();
	if(gtk_builder_add_from_string(builder, VIEWER_GLADE_STRING, strlen(VIEWER_GLADE_STRING), &err) == 0) {
		g_critical("Could not parse Glade XML: %s", err->message);
		exit(EXIT_FAILURE);
	}

	window = GTK_WIDGET(gtk_builder_get_object(builder, "mainwin"));
	group = gtk_accel_group_new();
	gtk_window_add_accel_group(GTK_WINDOW(window), group);

	touched_labels = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

	bindata_init();
	connect_signals(window);
	setup_treeview();

	certs_init();

	cb = eid_vwr_cbstruct();
	cb->newsrc = newsrc;
	cb->newstringdata = newstringdata;
	cb->newbindata = newbindata;
	cb->logv = ui_log_init();
	cb->newstate = newstate;
	cb->pinop_result = pinop_result;
	cb->readers_changed = readers_changed;
	eid_vwr_createcallbacks(cb);

	pthread_create(&thread, NULL, threadmain, NULL);

	G_GNUC_BEGIN_IGNORE_DEPRECATIONS
	logo = gdk_pixbuf_from_pixdata(&logo_128, FALSE, NULL);
	G_GNUC_END_IGNORE_DEPRECATIONS
	gtk_window_set_default_icon(logo);

	gtk_widget_show(window);

	if(argc > 1) {
		eid_vwr_be_deserialize(argv[1]);
	}

	gtk_main();

	return 0;
}