]> Pileus Git - ~andy/gtk/blobdiff - tests/testappchooser.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testappchooser.c
index a50f1b4e4cfcd45d71e2bb98c0f58b73de358793..221bd613ec133940f6cdc99c287d88fe502a73b9 100644 (file)
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <gtk/gtk.h>
 
@@ -26,7 +26,7 @@ static GFile *file;
 static GtkWidget *grid, *file_l, *open;
 static GtkWidget *radio_file, *radio_content, *dialog;
 static GtkWidget *app_chooser_widget;
-static GtkWidget *recommended, *fallback, *other, *all;
+static GtkWidget *def, *recommended, *fallback, *other, *all;
 
 static void
 dialog_response (GtkDialog *d,
@@ -41,10 +41,14 @@ dialog_response (GtkDialog *d,
   if (response_id == GTK_RESPONSE_OK)
     {
       app_info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (d));
-      name = g_app_info_get_name (app_info);
-      g_print ("Application selected: %s\n", name);
-
-      g_object_unref (app_info);
+      if (app_info)
+        {
+          name = g_app_info_get_name (app_info);
+          g_print ("Application selected: %s\n", name);
+          g_object_unref (app_info);
+        }
+      else
+        g_print ("No application selected\n");
     }
 
   gtk_widget_destroy (GTK_WIDGET (d));
@@ -54,6 +58,9 @@ dialog_response (GtkDialog *d,
 static void
 bind_props (void)
 {
+  g_object_bind_property (def, "active",
+                          app_chooser_widget, "show-default",
+                          G_BINDING_SYNC_CREATE);
   g_object_bind_property (recommended, "active",
                           app_chooser_widget, "show-recommended",
                           G_BINDING_SYNC_CREATE);
@@ -98,6 +105,8 @@ prepare_dialog (void)
                                                             0, content_type);
     }
 
+  gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), "Select one already, you <i>fool</i>");
+
   g_signal_connect (dialog, "response",
                     G_CALLBACK (dialog_response), NULL);
 
@@ -148,7 +157,6 @@ main (int argc, char **argv)
   GtkWidget *w1;
   gchar *path;
 
-  g_type_init ();
   gtk_init (&argc, &argv);
 
   toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -202,6 +210,11 @@ main (int argc, char **argv)
   gtk_grid_attach_next_to (GTK_GRID (grid), all,
                            other, GTK_POS_RIGHT, 1, 1);
 
+  def = gtk_check_button_new_with_label ("Show default");
+  gtk_grid_attach_next_to (GTK_GRID (grid), def,
+                           all, GTK_POS_RIGHT, 1, 1);
+
+  g_object_set (recommended, "active", TRUE, NULL);
   prepare_dialog ();
   g_signal_connect (open, "clicked",
                     G_CALLBACK (display_dialog), NULL);