コード例 #1
0
static void
gb_view_stack_move_top_list_row (GbViewStack *self,
                                 GbView      *view)
{
  GList *children;
  GList *iter;

  g_assert (GB_IS_VIEW_STACK (self));
  g_assert (GB_IS_VIEW (view));

  children = gtk_container_get_children (GTK_CONTAINER (self->views_listbox));

  for (iter = children; iter; iter = iter->next)
    {
      GtkWidget *row = iter->data;
      GbView *item = g_object_get_data (G_OBJECT (row), "GB_VIEW");

      if (item == view)
        {
          g_object_ref (row);
          gtk_container_remove (GTK_CONTAINER (self->views_listbox), row);
          gtk_list_box_prepend (self->views_listbox, row);
          gtk_list_box_select_row (self->views_listbox, GTK_LIST_BOX_ROW (row));
          g_object_unref (row);
          break;
        }
    }

  g_list_free (children);
}
コード例 #2
0
static void pocketvox_setup_add_module(PocketvoxSetup *setup, gchar* key, gchar* value, gboolean isapps)
{
	g_return_if_fail(NULL != setup);

   	setup->priv = G_TYPE_INSTANCE_GET_PRIVATE (setup,
			TYPE_POCKETVOX_SETUP, PocketvoxSetupPrivate);
	PocketvoxSetupPrivate *priv = setup->priv;

    ModuleInfos *info = (ModuleInfos *)g_malloc0(sizeof(ModuleInfos));

    GtkWidget* row          = gtk_list_box_row_new();
    gchar *name             = g_strdup_printf("row_%d",current_line);
    gtk_widget_set_name(row, name);

	GtkWidget* grid 	    = gtk_grid_new();
	info->entry_id	        = gtk_entry_new();

    if(key != NULL)
    {
        gtk_entry_set_text(GTK_ENTRY(info->entry_id), key);
    }

    gtk_entry_set_placeholder_text(GTK_ENTRY(info->entry_id), _("your-id"));
    gtk_widget_set_tooltip_text(info->entry_id, _("Set the module's id"));

	info->sw		        = gtk_switch_new();
    gtk_widget_set_tooltip_text(info->sw, _("is this module associated to an desktop application ?"));

	info->entry_path	    = gtk_entry_new();
	gtk_entry_set_icon_from_icon_name (GTK_ENTRY(info->entry_path), GTK_ENTRY_ICON_SECONDARY, "gtk-search");
    gtk_entry_set_placeholder_text(GTK_ENTRY(info->entry_path), _("your path"));
    gtk_widget_set_tooltip_text(info->entry_path,_("Set the dictionnary's path"));
	g_signal_connect(info->entry_path, "icon-press", G_CALLBACK(pocketvox_setup_search_dict), NULL);

	//gtk_widget_set_hexpand(label_app, TRUE);
	gtk_widget_set_hexpand(info->entry_path, TRUE);
	gtk_widget_set_hexpand(info->entry_id, TRUE);
	gtk_widget_set_hexpand(info->sw, FALSE);

	g_object_set(G_OBJECT(info->sw),
				"active", isapps,
				NULL);

    if(value != NULL)
    {
        gtk_entry_set_text(GTK_ENTRY(info->entry_path),
                                                value);
    }

    gtk_grid_set_row_homogeneous(GTK_GRID(grid), FALSE);
	gtk_grid_attach(GTK_GRID(grid), info->entry_id, 	0, 0, 2, 1);
	gtk_grid_attach(GTK_GRID(grid), info->entry_path, 	2, 0, 2, 1);
	gtk_grid_attach(GTK_GRID(grid), info->sw,			4, 0, 1, 1);

    gtk_container_add(GTK_CONTAINER(row), grid);
	gtk_widget_show_all(row);

	gtk_list_box_prepend(GTK_LIST_BOX(priv->listBox), row);

    g_hash_table_insert(priv->apps, g_strdup(name), info);

    current_line ++;
}